[OPEN] [#939] [3.2.1] Treestore has no changedData after edit

Page 1 of 2 12 LastLast
  1. #1

    [OPEN] [#939] [3.2.1] Treestore has no changedData after edit

    Hi,

    i have an TreeGrid with an TreeStore with an AjayProxy. So far everything works fine.
    In the TreeGrid are Columns with Editors,

    Example:
     <ext:Column runat="server" ID="ccName" Text="Name" DataIndex="Name" Width="75" Cls="headerCommon" ToolTip="Position" MenuDisabled="true">
    <Editor>
    <ext:TextField runat="server" ID="edtName" />
    </Editor>
    </ext:Column>
    If i change the data with the editor the row is marked as dirty and the red triangle appears on the cell.

    now i want to save the save, but there are NO changed/modified/udated records in the store.

    <ext:Button runat="server" Text="Save" Icon="Disk">
    <DirectEvents>
     <Click OnEvent="SaveClick" Before="return #{MainStore}.isDirty();">
        <ExtraParams>
           <ext:Parameter Name="RowValues" Value="#{MainStore}.getChangedData()" Mode="Raw" Encode="true" />
           <ext:Parameter Name="Close" Value="false" Mode="Raw" />
        </ExtraParams>
     </Click>
    </DirectEvents>
    i want to make an BatchUpdate. But i get no data!

    Sorry, but i cannot provied an example app.
    i hope you can help me.

    best regards
    I.
    Last edited by Daniil; Nov 19, 2015 at 6:58 AM. Reason: [OPEN] [#939] [3.2.1]
  2. #2
    Hi @IMehl,

    the row is marked as dirty and the red triangle appears on the cell
    It doesn't happen for me - an edited cell is not marked as dirty for me.

    I've tried with this example.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void NodeLoad(object sender, NodeLoadEventArgs e)
        {
            string prefix = e.ExtraParams["prefix"] ?? "";
    
            if (!string.IsNullOrEmpty(e.NodeID))
            {
                for (int i = 1; i < 6; i++)
                {
                    Node asyncNode = new Node();
                    asyncNode.Text = prefix + e.NodeID + i;
                    asyncNode.NodeID = e.NodeID + i;
                    e.Nodes.Add(asyncNode);
                }
    
                for (int i = 6; i < 11; i++)
                {
                    Node treeNode = new Node();
                    treeNode.Text = prefix + e.NodeID + i;
                    treeNode.NodeID = e.NodeID + i;
                    treeNode.Leaf = true;
                    e.Nodes.Add(treeNode);
                }
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TextField ID="TextField1" runat="server" Text="Node" Width="200" />
            
            <ext:TreePanel 
                ID="TreePanel1" 
                runat="server" 
                Title="Tree"
                Width="200"
                Height="500" 
                Border="false">
                <Store>
                    <ext:TreeStore runat="server" OnReadData="NodeLoad">
                        <Proxy>
                            <ext:PageProxy />
                        </Proxy>
                        <Parameters>
                            <ext:StoreParameter Name="prefix" Value="App.TextField1.getValue()" Mode="Raw" />
                        </Parameters>
                    </ext:TreeStore>
                </Store>
                <Root>
                    <ext:Node NodeID="0" Text="Root" />
                </Root>
                <ColumnModel>
                    <Columns>
                        <ext:TreeColumn runat="server" DataIndex="text" />
                        <ext:Column runat="server" DataIndex="text">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:CellEditing runat="server" />
                </Plugins>
            </ext:TreePanel>       
        </form>
    </body>
    </html>
    There is a possible solution.
    http://forums.ext.net/showthread.php...l=1#post274249
  3. #3

    Changed example

    Hi,

    thanks for the example. I have modified this to reproduce the error.

    If you edit the column "Text" and press Save there are NO UpdatedRecords. If you edit the Column "Text1" or "Text2" and press Save, then you get
    updated records. Why not at column "Text"?

    On the "Text" cell there are NOT red triangle, but on the other cells you can see it.

    best regards
    I.

    <%@ Page Language="C#" %>
    
    <script>
        
        var onSaveClick = function (btn, e, eOpts) {
    
            console.log(App.MainStore);
            console.log(App.MainStore.getChangedData());
            console.log(App.MainStore.getModifiedRecords());
            console.log(App.MainStore.getUpdatedRecords());
        }
    </script>
    
    <script runat="server">
        protected void NodeLoad(object sender, NodeLoadEventArgs e)
        {
            string prefix = e.ExtraParams["prefix"] ?? "";
    
            if (!string.IsNullOrEmpty(e.NodeID))
            {
                for (int i = 1; i < 6; i++)
                    {
                        Node asyncNode = new Node();
                        asyncNode.Text = "Node" + i;
                        asyncNode.NodeID = "Node" + i;
                        asyncNode.Expanded = true;
                        asyncNode.Leaf = true;
    
                        asyncNode.CustomAttributes.Add(new ConfigItem() { Name = "text1", Value = "Text1-" + i, Mode = ParameterMode.Auto });
                        asyncNode.CustomAttributes.Add(new ConfigItem() { Name = "text2", Value = "Text2-" + i, Mode = ParameterMode.Value });
    
                        e.Nodes.Add(asyncNode);
                    }
            }
        }
    </script>
    
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TextField ID="TextField1" runat="server" Text="Node" Width="200" />
            
            <ext:TreePanel
                runat="server"
                SortableColumns="false"
                ID="TreeGrid1"
                Title="Project Calculator"
                MinHeight="400"
                MaxHeight="800"
                RootVisible="false"
                MultiSelect="false"
                Border="false"
                Mode="Local"
                SingleExpand="false"
                FolderSort="false">
                <SelectionSubmitConfig Encode="true" />
                <Store>
                    <ext:TreeStore runat="server" ID="MainStore" OnReadData="NodeLoad">
                        <Proxy>
                            <ext:PageProxy/> 
                        </Proxy>
                        <Parameters>
                            <ext:StoreParameter Name="prefix" Value="App.TextField1.getValue()" Mode="Raw" />
                        </Parameters>
                    </ext:TreeStore>
                </Store>
                <Root>
                    <ext:Node NodeID="0" Text="Root" Expanded="true" />
                </Root>
                <TopBar>
                    <ext:Toolbar runat="server" Flat="true">
                        <Items>
                            <ext:Button runat="server" Text="Save" Icon="Disk">
                                <Listeners>
                                    <Click Fn="onSaveClick"></Click>
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel>
                    <Columns>
                       <ext:TreeColumn runat="server" DataIndex="text" />
                        <ext:Column runat="server" DataIndex="text" Text="Text">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                        <ext:Column runat="server" DataIndex="text1" Text="Text1">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                        <ext:Column runat="server" DataIndex="text2" Text="Text2">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:CellEditing runat="server" ClicksToEdit="1"/>
                </Plugins>
            </ext:TreePanel>       
        </form>
    </body>
    </html>
  4. #4
    Thank you for the test case. I will investigate.
  5. #5
    Yes, that happens because of:
    https://www.sencha.com/forum/showthr...=1#post1101583

    This appears to help:
    Ext.data.NodeInterface.decorate = Ext.Function.createSequence(Ext.data.NodeInterface.decorate, function (modelClass) {
        var model = Ext.data.schema.Schema.lookupEntity(modelClass);
    
        if (model && model.fieldsMap && model.fieldsMap["text"]) {
            model.fieldsMap["text"].persist = true;
        }
    });
    I've logged this Issue in GitHub:
    https://github.com/extnet/Ext.NET/issues/939
  6. #6
    Thanks Daniil.

    Now i changed the Store an set alle fields "persist=true". But the it will change nothing.

    <Store>
                    <ext:TreeStore runat="server" ID="MainStore" OnReadData="NodeLoad">
                        <Proxy>
                            <ext:PageProxy/> 
                        </Proxy>
                        <Model>
                            <ext:Model runat="server" ID="mdlTest">
                                <Fields>
                                    <ext:ModelField Name="Text" Type="String" Persist="True"/>
                                    <ext:ModelField Name="Text1" Type="String" Persist="True"/>
                                    <ext:ModelField Name="Text2" Type="String" Persist="True"/>
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Parameters>
                            <ext:StoreParameter Name="prefix" Value="App.TextField1.getValue()" Mode="Raw" />
                        </Parameters>
                    </ext:TreeStore>
                </Store>
    If i use your code, i will get always the "Ext is not defined" error.

    best regards
    I.
  7. #7
    Please try to change Name="Text" to Name="text".
    Last edited by Daniil; Nov 26, 2015 at 8:23 AM.
  8. #8
    Hi,

    ist this not the same?

    best regards
    Thorsten
  9. #9
    Sorry. I've corrected the post. Please note the lowercase "t" in "text" that it should be changed to.
  10. #10
    Hi,

    now i have extend the sample to create the Root Node in Codebehind.
    If i click the root node, and change the text, the row will not appear in the modified Records. Why?

    <%@ Page Language="C#" %>
    
    <script type="text/javascript">
        
       var onSaveClick = function (btn, e, eOpts) {
    
            console.log(App.MainStore);
            console.log(App.MainStore.getChangedData());
            console.log(App.MainStore.getModifiedRecords());
            console.log(App.MainStore.getUpdatedRecords());
       }
    
       var onItemClick = function (view, rec) {
    
           console.log('onItemClick');
           console.log(rec);
           //if (rec.get('leaf')) {
               rec.set('qtip', 'Changed');
               var panel = App.TreeGrid1,
                   store = panel.getStore(),
                   consolePanel = App.Panel1,
                   recs = new Array();
                				
               for(i=0; i<store.getCount(); i++)
                   recs.push(store.getAt(i).get('qtip'));
                                
               consolePanel.add({
                   xtype: 'box',
                   autoEl: {
                       cn: ' > ' +
                           'modifiedRecords: ' +
                           store.getModifiedRecords().length +
                           ' -> ' + recs.join(', ')
                   }
               });
                                
               //console.log(store.getModifiedRecords());
           //}
       }
    
    </script>
    
    <script runat="server">
    
            protected void Page_Load(object sender, EventArgs e)
        {
            Node root = new Node {NodeID = "Root0", Text="RootNode", Expanded = true};
            root.CustomAttributes.Add(new ConfigItem() { Name = "text1", Value = "Root1", Mode = ParameterMode.Auto });
            root.CustomAttributes.Add(new ConfigItem() { Name = "text2", Value = "Root2", Mode = ParameterMode.Value });
    
            TreeGrid1.Root.Add(root);
    
        }
    
    
        protected void NodeLoad(object sender, NodeLoadEventArgs e)
        {
            string prefix = e.ExtraParams["prefix"] ?? "";
    
            if (!string.IsNullOrEmpty(e.NodeID))
            {
                for (int i = 1; i < 6; i++)
                {
                    Node asyncNode = new Node();
                    asyncNode.Text = "Node" + i;
                    asyncNode.NodeID = "Node" + i;
                    asyncNode.Expanded = true;
                   
                    asyncNode.CustomAttributes.Add(new ConfigItem() { Name = "text1", Value = "Text1-" + i, Mode = ParameterMode.Auto });
                    asyncNode.CustomAttributes.Add(new ConfigItem() { Name = "text2", Value = "Text2-" + i, Mode = ParameterMode.Value });
    
                    if (i < 3)
                    {
    
                        for (int x = 1; x < 3; x++)
                        {
                            Node childNode = new Node
                            {
                                Text = "Node" + i + x,
                                NodeID = "Node" + i + x,
                                Expanded =false,
                                Leaf = true
                            };
    
                            childNode.CustomAttributes.Add(new ConfigItem() {Name = "text1", Value = "Text1-" + i, Mode = ParameterMode.Auto});
                            childNode.CustomAttributes.Add(new ConfigItem() {Name = "text2", Value = "Text2-" + i, Mode = ParameterMode.Value});
    
                            asyncNode.Children.Add(childNode);
                        }
                    }
    
                    if (asyncNode.Children.Count > 0)
                    {
                        asyncNode.Leaf = false;
                    }
                    else
                    {
                        asyncNode.Leaf = true;
                    }
    
                    e.Nodes.Add(asyncNode);
                }
            }
    
        }
    
    
    </script>
    
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
        
       
    </head>
    <body>
        <form runat="server">
    
            <ext:ResourceManager runat="server" Theme="Default" InitScriptMode="Inline" ScriptMode="Debug" ID="ResourceManager1" />
    
            <ext:TextField ID="TextField1" runat="server" Text="Node" Width="200" />
            
            <ext:TreePanel
                runat="server"
                SortableColumns="false"
                ID="TreeGrid1"
                Title="Test"
                MinHeight="400"
                MaxHeight="800"
                RootVisible="true"
                MultiSelect="false"
                Border="false"
                Mode="Local"
                SingleExpand="false"
                FolderSort="false">
                <SelectionSubmitConfig Encode="true" />
                <Store>
                    <ext:TreeStore runat="server" ID="MainStore" OnReadData="NodeLoad">
                        <Proxy>
                            <ext:PageProxy/> 
                        </Proxy>
                        <Model>
                            <ext:Model runat="server" ID="mdlTest">
                                <Fields>
                                    <ext:ModelField Name="text" Type="String" Persist="True"/>
                                    <ext:ModelField Name="text1" Type="String" Persist="True"/>
                                    <ext:ModelField Name="text2" Type="String" Persist="True"/>
                                    <ext:ModelField Name="qtip" Type="String" Persist="True"/>
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Parameters>
                            <ext:StoreParameter Name="prefix" Value="App.TextField1.getValue()" Mode="Raw" />
                        </Parameters>
                    </ext:TreeStore>
                </Store>
                <%--<Root>
                    <ext:Node NodeID="0" Text="Root" Expanded="true" />
                </Root>--%>
                <TopBar>
                    <ext:Toolbar runat="server" Flat="true">
                        <Items>
                            <ext:Button runat="server" Text="Save" Icon="Disk">
                                <Listeners>
                                    <Click Fn="onSaveClick"></Click>
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel>
                    <Columns>
                       <ext:TreeColumn runat="server" DataIndex="text" />
                        <ext:Column runat="server" DataIndex="text" Text="Text">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                        <ext:Column runat="server" DataIndex="text1" Text="Text1">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                        <ext:Column runat="server" DataIndex="text2" Text="Text2">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                        <ext:Column runat="server" DataIndex="leaf" Text="IsLeaf"/>
                        <ext:Column runat="server" DataIndex="qtip" Text="qTip"/>
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:CellEditing runat="server" ClicksToEdit="1"/>
                </Plugins>
                <Listeners>
                    <ItemClick Fn="onItemClick"/>
                </Listeners>
            </ext:TreePanel>
    
            <ext:Panel runat="server" ID="Panel1" Title="Console" BodyStyle="padding: 5px"/>  
        </form>
    </body>
    </html>
    best regards
    I.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] TreeGrid with treestore
    By vmehta in forum 3.x Legacy Premium Help
    Replies: 8
    Last Post: Nov 19, 2015, 6:54 AM
  2. Replies: 6
    Last Post: Feb 12, 2015, 10:43 AM
  3. [CLOSED] how to enumerate treestore?
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 31, 2014, 11:30 AM
  4. [CLOSED] TreeStore with IHierarchicalDataSource
    By bbros in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Oct 26, 2013, 9:25 AM
  5. [CLOSED] TreeStore issue with 2.2
    By paulc in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 19, 2013, 9:24 AM

Posting Permissions