[CLOSED] Treepanel expand path

Page 1 of 2 12 LastLast

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Treepanel expand path

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

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

    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
  3. #3

    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

    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)


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

    Or load all nodes at once
  5. #5

    RE: [CLOSED] Treepanel expand path

    Hi Vladsch

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

    
    
    
    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

    RE: [CLOSED] Treepanel expand path

    Hi,

    Please see the following sample
    <%@ 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>
  7. #7

    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?

    
    
    
    
    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

    RE: [CLOSED] Treepanel expand path

    Hi,

    Can you post full example which demonstrates your last issue?
  9. #9

    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

    
    <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.

    
    
    
    
    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

    
        <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

    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
    node.ensureVisible(function(){node.select();});
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] How do I disable the TreePanel expand on double click
    By Labyrinth in forum 1.x Legacy Premium Help
    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