[CLOSED] Grid cell still shows as dirty after commiting store changes

  1. #1

    [CLOSED] Grid cell still shows as dirty after commiting store changes

    Hello,

    After saving store changes I am calling GridPanel.store.commitChanges(); (or Store.commitChanges() ). Changes are committed but changed cells still show red dirty flag. As far as I understood from the previous posts, calling commitChanges should be enough. Do I have to refresh grid view also after commitChanges? In this case is it possible to refresh changed rows only? (It is a grid panel with plenty of rows with heavy rendering cost).

    Thanks.
    Last edited by Daniil; Mar 19, 2013 at 4:24 AM. Reason: [CLOSED]
  2. #2
    Hi @bayoglu,

    Yes, a commitChanges call should be enough to remove dirty flags.

    Please provide a sample to reproduce.
  3. #3
    Hello Daniil,

    Below is a simplified (as I could) sample code. I removed the server logic just calling commitChanges. After save, record is not dirty and save button is disabled. However the red dirty icon still appears in the edited cell.

    Note-1: Edit "Value" column and click Save button to test.
    Note-2: MyStore AutoLoad is false for render purposes.
    Note-3: I need to use UseNull=true for ValueField if it makes sense.

    Thanks for quick response.

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.MyStore.DataSource = new List<object>
                {
                    new {
                            ID = 1,
                            NameID = 1,
                            Value = 3
                        },
                    new {
                            ID = 2,
                            NameID = 1,
                            Value = 5
                        },
                    new {
                            ID = 3,
                            NameID = 2,
                            Value = 7
                        },
                    new {
                            ID = 4,
                            NameID = 2,
                            Value = 6
                        },
                    new {
                            ID = 5,
                            NameID = 3,
                            Value = 9
                        }                                                                                                   
                };
                this.MyStore.DataBind();
    
                this.NameStore.DataSource = new List<object>
                {
                    new {
                            ID = 1,
                            Name = "Bond"
                        },
                    new {
                            ID = 2,
                            Name = "James Bond"
                        },
                    new {
                            ID = 3,
                            Name = "Bond Jr."
                        }                                                                                            
                };
            }
        }
    
     
    </script>
    <script type="text/javascript">
        function MyCellEditingHandler(item, e) {
            if (App.MyStore.isDirty()) {
                App.MyButton.enable();
            }
            else {
                App.MyButton.disable();
            }
        }
    
        function MyRenderer(value) {
            return App.NameStore.getById(value).data.Name;
        }
    
        function SaveGrid() {
            App.MyStore.commitChanges();
            if (!App.MyStore.isDirty()) {
                App.MyButton.disable();
            }
        }
    
    </script>
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Ext.NET Examples</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" SourceFormatting="True" />
            <ext:Store ID="MyStore" runat="server" AutoLoad="false">
                <Model>
                    <ext:Model ID="MyStoreModel" runat="server" IDProperty="ID">
                        <Fields>
                            <ext:ModelField Name="ID" Type="Int"></ext:ModelField>            
                            <ext:ModelField Name="NameID" Type="Int"></ext:ModelField>
                            <ext:ModelField Name="Value" Type="Int" UseNull="true"></ext:ModelField>
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>   
            <ext:Store ID="NameStore" runat="server">
                <Model>
                    <ext:Model ID="NameStoreModel" runat="server" IDProperty="ID">
                        <Fields>
                            <ext:ModelField Name="ID" Type="Int"></ext:ModelField>
                            <ext:ModelField Name="Name" Type="String"></ext:ModelField>                        
                        </Fields>
                    </ext:Model>
                </Model>
                <Listeners>
                    <Load Handler="App.MyGrid.store.load();"></Load>
                </Listeners>
            </ext:Store> 
            <ext:GridPanel ID="MyGrid" runat="server" StoreID="MyStore" MinHeight="200" Collapsible="false" Flex="1" Title="My Form" SelectionMemory="false">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server" EnableOverflow="true">
                        <Items>
                            <ext:ToolbarFill />
                            <ext:Button ID="MyButton" runat="server" Icon="Disk" Disabled="true">
                                <Listeners>
                                    <Click Handler="SaveGrid()"></Click>
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel runat="server" ID="MyColumnModel">
                    <Columns>
                        <ext:Column ID="Name" runat="server" Text="Name" DataIndex="NameID" Align="Left" Flex="1">
                            <Renderer Fn="MyRenderer"></Renderer>
                        </ext:Column>
                        <ext:Column ID="Value" runat="server" Text="Value" DataIndex="Value" Align="Left" Flex="1">
                            <Editor>
                                <ext:NumberField runat="server" ID="RankEditor" AllowDecimals="false" AllowBlank=true></ext:NumberField>
                            </Editor>                        
                        </ext:Column>                                                                                                                                                                 
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:CellSelectionModel ID="MyCellSelectionModel" runat="server" Mode="Single">
                    </ext:CellSelectionModel>
                </SelectionModel>
                <Plugins>
                    <ext:CellEditing ID="MyCellEditing" runat="server">
                        <Listeners>
                            <Edit Handler="MyCellEditingHandler(item,e);"></Edit>
                        </Listeners>
                    </ext:CellEditing>
                </Plugins>      
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by bayoglu; Mar 12, 2013 at 6:42 PM.
  4. #4
    Hello!

    Thank you for your example. I was able to reproduce it with trunk but with 2.1.1 everything is OK. We have reported to Sencha the similar issue with reject method: http://www.sencha.com/forum/showthread.php?257913 . Let's wait their answer about this one.

    For now, you should refresh Grid's view:

    function SaveGrid() {
    	App.MyStore.commitChanges();
    	App.MyGrid.view.refresh();
    	if (!App.MyStore.isDirty()) {
    		App.MyButton.disable();
    	}
    }
  5. #5
    Hello!
    I will follow the thread for a possible fix from @Sencha and corresponding trunk update.
    Thanks for your attention.

Similar Threads

  1. Replies: 4
    Last Post: Jun 20, 2012, 7:36 PM
  2. Replies: 2
    Last Post: Jun 06, 2012, 8:27 PM
  3. [CLOSED] Update grid cell value without store.reload()
    By pj_martins in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 02, 2011, 3:54 PM
  4. [CLOSED] Update only dirty cell in the row of gridpanel
    By Shanth in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 17, 2011, 12:46 PM
  5. Store - Determine if dirty?
    By Tbaseflug in forum 1.x Help
    Replies: 4
    Last Post: Dec 02, 2010, 1:29 PM

Posting Permissions