[FIXED] [#143] Expand TreePanel Node in OnReadData

Page 1 of 2 12 LastLast
  1. #1

    [FIXED] [#143] Expand TreePanel Node in OnReadData

    Hi,
    I've got some strange behavior when refreshing a TreeStore, using a reload. When I add nodes with Expanded="true", the nodes are not added to the correct parent. Also the ExpandAll Tree method does not work (it only works with the initial load).
    I'm using Ext.NET : version 2.1.0.28896
    Best regards,

    Sander

    Click image for larger version. 

Name:	tree.png 
Views:	222 
Size:	18.3 KB 
ID:	5537

    
    <%@ Page Language="C#" EnableViewState="true" %>
    
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <script runat="server">
        protected void NodeLoad(object sender, NodeLoadEventArgs e)
        {
            var node1 = new Ext.Net.Node
            {
                NodeID = "node1",
                Text = "Node 1 " + DateTime.Now.Ticks.ToString(),
                Icon = Icon.Bricks,
                Expanded = true,
                Leaf = false,
            };
            e.Nodes.Add(node1);
    
    
            var node2 = new Ext.Net.Node
            {
                NodeID = "node2",
                Text = "Node 2",
                Icon = Icon.Bricks,
                Leaf = false
            };
            node1.Children.Add(node2);
    
    
            var node3 = new Ext.Net.Node
            {
                NodeID = "node3",
                Text = "Node 3",
                Icon = Icon.Bricks,
                Leaf = true
            };
            node2.Children.Add(node3);
    
    
            PGTree.ExpandAll();
        }
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Tree Reload test</title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <form id="Form1" runat="server">
            <ext:TreePanel ID="PGTree" runat="server"
                RootVisible="false"
                Mode="Local"
                Height="400">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Button runat="server" Text="Refresh" ID="RefreshButton">
                                <Listeners>
                                    <Click Handler="#{PGTreeStore}.reload();" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:TreeStore ID="PGTreeStore" runat="server" OnReadData="NodeLoad" />
                </Store>
                <Root>
                    <ext:Node Text="Root" Expanded="true" />
                </Root>
                <SelectionModel>
                    <ext:TreeSelectionModel ID="DefaultSelectionModel1" Mode="Single" runat="server" />
                </SelectionModel>
            </ext:TreePanel>
        </form>
    </body>
    </html>
    Last edited by Baidaly; Feb 05, 2013 at 10:58 PM. Reason: [OPEN] [#143]
  2. #2
    Hi Sander,

    the nodes are not added to the correct parent
    I can't reproduce it either with the 2.1 release or with the Ext.NET sources from SVN trunk.

    What exactly are the steps?

    Also the ExpandAll Tree method does not work (it only works with the initial load
    An ExpandAll should be called after the nodes are actually loaded. I can suggest to attach a client side listener to the TreePanel's Load event.
    PGTree.On("load", "function () { this.expandAll(); }", null, new HandlerConfig() { Single = true });
    Though it might be simpler to just specify "Expanded = true" for all non-leaf nodes to get them expanded.
  3. #3
    Hi Danill,

    Now I only set node1 as Expanded.

    <%@ Page Language="C#" EnableViewState="true" %>
    
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <script runat="server">
        protected void NodeLoad(object sender, NodeLoadEventArgs e)
        {
            var node1 = new Ext.Net.Node
            {
                NodeID = "node1",
                Text = "Node 1 " + DateTime.Now.Ticks.ToString(),
                Icon = Icon.Bricks,
                Expanded = true,
                Leaf = false,
            };
            e.Nodes.Add(node1);
    
    
            var node2 = new Ext.Net.Node
            {
                NodeID = "node2",
                Text = "Node 2",
                Icon = Icon.Bricks,
                Leaf = false
            };
            node1.Children.Add(node2);
    
    
            var node3 = new Ext.Net.Node
            {
                NodeID = "node3",
                Text = "Node 3",
                Icon = Icon.Bricks,
                Leaf = true
            };
            node2.Children.Add(node3);
        }
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Tree Reload test</title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <form id="Form1" runat="server">
            <ext:TreePanel ID="PGTree" runat="server"
                RootVisible="false"
                Mode="Local"
                Height="400">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Button runat="server" Text="Refresh" ID="RefreshButton">
                                <Listeners>
                                    <Click Handler="#{PGTreeStore}.reload();" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:TreeStore ID="PGTreeStore" runat="server" OnReadData="NodeLoad" />
                </Store>
                <Root>
                    <ext:Node Text="Root" Expanded="true" />
                </Root>
            </ext:TreePanel>
        </form>
    </body>
    </html>
    When the page is initially loaded, it looks as expected.

    Click image for larger version. 

Name:	tree.png 
Views:	145 
Size:	17.6 KB 
ID:	5538

    When I press the Refresh button, the page refreshes and looks ok. I expect the total tree to be reloaded, but when I try to expand Node2, the OnReadData event is raised (to add childs of Node2). In my code I don't add only childs of Node2, but refresh the total tree, so this is the result of the expand:

    Click image for larger version. 

Name:	Tree2.png 
Views:	164 
Size:	18.1 KB 
ID:	5539

    I assumed that the OnReadData was only raised when a node is expanded by the user, and the node was not already initialized with child nodes. But this seems not true.
    Is it correct that the OnReadData must be able to return childs of any node expanded by the user, even if the childs were already created in an initial load?

    Thanks!
    Sander
  4. #4
    You add nodes with Leaf="false" and Expanded="true". It forces a separate load request for each such node. I.e. the NodeLoad handler is executed again and it produces the nodes for the same ids. The ids must be unique.

    To avoid load requests for such nodes you could set up EmptyChildren="true" for them.
    Last edited by Baidaly; Feb 05, 2013 at 10:55 PM.
  5. #5
    Hi Daniil,
    Thanks for your answer, but I still don't understand the following:

    1) Page is loaded, NodeLoad is called 3 nodes are added to the root.
    2) When I click on collapsed Node2, the node is expanded, Node3 gets visible, there is no call to NodeLoad, because Node2 has a child.

    So far it works as expected...

    3) Click the refresh butten, in javascript the TreeStore.reload() is called. Like in step 1, the NodeLoad is called, again 3 nodes are added to the root.
    4) Now click again on collapsed Node2, but contrary to step 2, de NodeLoad is called to add children to Node2. Why is NodeLoad called, in step 3 the node gets Node3 as a child?

    Thanks,
    Sander
  6. #6
    Agree, it is inconsistent.

    I think it should behave the same after reloading.

    We are investigating.
  7. #7
    Hi,

    Sencha opened a bug
    http://www.sencha.com/forum/showthre...re-with-proxy)

    We will include a fix to Ext.Net after Sencha releases the fix
  8. #8
    Hello!

    Issue was created to monitor.

    https://github.com/extnet/Ext.NET/issues/143
  9. #9
    Hi,
    Is there any information available how long it will take the problem is solved?
    Tanks,
    Sander
  10. #10
    Unfortunately, we have no such information, Sencha doesn't provide us info about bugs fixing
    At this moment, I can suggest update tree panel if you need to reload tree store

    1. Set for Button
    OnDirectClick="RefreshButton_DirectClick"
    2. In the server side handler call
     PGTree.Update();
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Select node after expand in TreePanel
    By multimediait in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 17, 2014, 9:11 AM
  2. Treepanel - Expand Node on Single Click - How to?
    By Tbaseflug in forum 2.x Help
    Replies: 1
    Last Post: Dec 12, 2012, 11:31 AM
  3. TreePanel expand node behaviour
    By web4u in forum 2.x Help
    Replies: 1
    Last Post: Aug 28, 2012, 1:02 PM
  4. Replies: 0
    Last Post: Mar 16, 2010, 7:26 PM
  5. TreePanel node expand button IE8
    By methode in forum 1.x Help
    Replies: 8
    Last Post: Sep 08, 2009, 4:00 AM

Posting Permissions