Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: [CLOSED] Treepanel expand path

  1. #1
    Premium Member
    Join Date
    Feb 2009
    Posts
    122

    [CLOSED] Treepanel expand path

    In your examples you can get a direct link to the page Like this:
    http://examples1.ext.net/#/Desktop/I...tion/Overview/

    Is there a way to refresh the treepanel with this link so the entire path is shown (expanded)?

  2. #2
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,157

    RE: [CLOSED] Treepanel expand path

    Hi,

    Please see Ext.Net Examples Explorer (in the SVN). It expands tree node if you use direct link (see main.js)


    You have to map link to the node id (we use hash code of the link as tree node id), after that find node by id (use getNodeById method of the tree, please ensure that all nodes are loaded already (you can use load listener of the tree) ) and call ensureVisible method of the tree node
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  3. #3
    Premium Member
    Join Date
    Feb 2009
    Posts
    122

    RE: [CLOSED] Treepanel expand path

    I'm using Async loader in .82. I can find the root node with getNodeById, but not any of the children. How can I find the children?

  4. #4
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,157

    RE: [CLOSED] Treepanel expand path

    Hi,

    If you use async loader to load children for each node then you cannot find nodes until parent node loads own children.
    You have to manually expand all parent nodes first (expand first parent node, in the callback expand next node and etc)


    Code:
    node1.expand(false, false, function(){node2.expand(...);})

    Or load all nodes at once
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  5. #5
    Premium Member
    Join Date
    Feb 2009
    Posts
    122

    RE: [CLOSED] Treepanel expand path

    Hi Vladsch

    Here is the code I'm using to expand the nodes:

    Code:
    
    
    TreePanel1_1.AddScript("TreePanel1_1.getNodeById('AAA_ROOT').expand(false,false,function() {TreePanel1_1.getNodeById('PUB_0001').expand(false,false)});")
    It seems to find the root, but not the child. Am I calling this function correctly?


  6. #6
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,157

    RE: [CLOSED] Treepanel expand path

    Hi,

    Please see the following sample
    Code:
    <%@ Page Language="C#" %>
    
    <%@ 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">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>TreePanel with Async TreeLoader using Page - Ext.NET Examples</title>
        
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
        
        <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++)
                    {
                        AsyncTreeNode asyncNode = new AsyncTreeNode();
                        asyncNode.Text = prefix + e.NodeID + i;
                        asyncNode.NodeID = e.NodeID + i;
                        e.Nodes.Add(asyncNode);
                    }
    
                    for (int i = 6; i < 11; i++)
                    {
                        Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode();
                        treeNode.Text = prefix + e.NodeID + i;
                        treeNode.NodeID = e.NodeID + i;
                        treeNode.Leaf = true;
                        e.Nodes.Add(treeNode);
                    }
                }
            }
        </script>
        
        <script type="text/javascript">
            function openNode(ids, i){
                i = i || 0;
                if(ids.length == (i+1)){
                    var node = TreePanel1.getNodeById(ids[i]);
                    node.ensureVisible();
                    node.select();
                }
                else{
                    TreePanel1.getNodeById(ids[i]).expand(false, false, openNode.createDelegate(this, [ids, ++i]));
                }
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <h1>TreePanel using PageTreeLoader</h1> 
            
            <p>Set custom node prefix: </p>
            <ext:TextField ID="TextField1" runat="server" Text="Node" />
            
            <ext:TreePanel 
                ID="TreePanel1" 
                runat="server" 
                Title="Tree" 
                AutoHeight="true" 
                Border="false">
                <Loader>
                    <ext:PageTreeLoader OnNodeLoad="NodeLoad">
                        <BaseParams>
                            <ext:Parameter Name="prefix" Value="#{TextField1}.getValue()" Mode="Raw" />
                        </BaseParams>
                    </ext:PageTreeLoader>
                </Loader>
                <Root>
                    <ext:AsyncTreeNode NodeID="0" Text="Root" />
                </Root>
            </ext:TreePanel>    
            
            <ext:Button runat="server" Text="Open Node01349">
                <Listeners>
                    <Click Handler="openNode(['0', '01', '013', '0134', '01349'])" />
                </Listeners>
            </ext:Button>   
        </form>
    </body>
    </html>
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  7. #7
    Premium Member
    Join Date
    Feb 2009
    Posts
    122

    RE: [CLOSED] Treepanel expand path



    Hi Vladsch

    Everything works good except that I had to modify the js code to make a call to load the iframe. See code below. The problem is when I call openNode the first time it opens the nodes but does not select the leaf and does not execute the callback. When I click the button again, it selects the leaf and makes the callback. I'm assuming this worked because the nodes were already expanded. Any ideas?

    Is there a delay issue here?

    Code:
    
    
    
    function openNode(ids, i) {
    
    
    i = i || 0;
    
    
    if (ids.length == (i + 1)) {
    
    
    var node = TreePanel1_1.getNodeById(ids[i]);
    
    
    node.ensureVisible();
    
    
    node.select();
    
    
    Coolite.AjaxMethods.TreePanel_ClickJS(ids[i]);
    
    
    } else {
    
    
    TreePanel1_1.getNodeById(ids[i]).expand(false, false,
    
    
    openNode.createDelegate(this, [ids, ++i]));
    
    
    }
    
    
    }

  8. #8
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,157

    RE: [CLOSED] Treepanel expand path

    Hi,

    Can you post full example which demonstrates your last issue?
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  9. #9
    Premium Member
    Join Date
    Feb 2009
    Posts
    122

    RE: [CLOSED] Treepanel expand path



    Here is the code starting with the button. Node PUB_0050 is a leaf node tied to a table record with a URL

    Code:
    <ext:Toolbar ID="ToolBar2" runat="server">
    
    
    <Items>
    
    
    <ext:Button ID="Button1" runat="server" Text="Open Node01349">
    
    
    <Listeners>
    
    
    <Click Handler="openNode(['AAA_ROOT','PUB_0004','PUB_0050'])" />
    
    
    </Listeners>
    
    
    </ext:Button>
    
    
    </Items>
    
    
    </ext:Toolbar>
    Then we have the Javascript code to expand the nodes. A call is made to Coolite.AjaxMethods.TreePanel_ClickJS to get the URL.

    Code:
    
    
    
    function openNode(ids, i) {
    
    
    i = i || 0;
    
    
    if (ids.length == (i + 1)) {
    
    
    Coolite.AjaxMethods.TreePanel_ClickJS(ids[i]);
    
    
    var node = TreePanel1_1.getNodeById(ids[i]);
    
    
    node.ensureVisible();
    
    
    node.select();
    
    
    } else {
    
    
    TreePanel1_1.getNodeById(ids[i]).expand(false, false,
    
    
    openNode.createDelegate(this, [ids, ++i]));
    
    
    }
    
    
    }
    Here is the AjaxMethod to load the iframe witht he URL

    Code:
        <AjaxMethod()> _
        Public Sub TreePanel_ClickJS(ByVal NodeId As String)
            Dim NavigateURL As String = "/Common/Pages/WebUnderConstruction.aspx"
    
    
                Dim bo As New DCPMenus(DCPUtil_ConfigSettingsWeb.DBConnection)
                bo.NodeID = NodeId
                bo.WhereFilter = DCPMenusDC.WhereFilters.NodeID
                bo.Open(True)
                If String.IsNullOrEmpty(bo.NavigateUrl) Then
                 Pages.AutoLoad.Url = NavigateURL
                Else
                 Pages.AutoLoad.Url = bo.NavigateUrl
                End If
                Pages.AutoLoad.Mode = LoadMode.IFrame
                Pages.AutoLoad.NoCache = True
                Pages.LoadContent()
                
        End Sub
    If I click the button once, it does expand the tree out as intented, but does not load the iframe with the URL. If I click the button a second time, it loads the URL into the iframe like I need it to do the first time I click the button.

  10. #10
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,157

    RE: [CLOSED] Treepanel expand path

    Hi,

    We need full sample. Can you modify my sample to demonstrate the problem?


    Also you can try to set selection in 'ensureVisible' callback
    Code:
    node.ensureVisible(function(){node.select();});
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

Similar Threads

  1. Replies: 2
    Last Post: Dec 12, 2012, 11:47 AM
  2. TreePanel expand node behaviour
    By web4u in forum 2.x Help
    Replies: 1
    Last Post: Aug 28, 2012, 1:02 PM
  3. Treepanel: expand ~1500 nodes gives error
    By RobOtter in forum 1.x Help
    Replies: 3
    Last Post: Jul 14, 2011, 12:33 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