[CLOSED] Expanding tree programmatically

  1. #1

    [CLOSED] Expanding tree programmatically

    Hi,

    Is it possible to expand a treepanel to a node from the code behind?

    I have an application that stores the last node selection that a user has made in a database and I want to make the website in such a way that next time it opens with the last selected node.

    The treepanel contains a treestore with the method 'OnReadData' to fill the tree when nodes are selected.

    Any idea how to approach this? In VB/C# or in the javascript part of ext.net?
    Is it possible when not all data is loaded?

    Hans Wapenaar
    Last edited by Daniil; Apr 17, 2015 at 4:53 PM. Reason: [CLOSED]
  2. #2
    In OnReadData set the node's Expanded property accordingly.
  3. #3
    Ok, but I thought that OnReadData works when the user clicks on a node in the treepanel. After the user clicks on a node the contents of the ChildNodes is filled and the node is expanded.
    What I'm searching for is a method to expand a node programatically and not through the user interface.
  4. #4
    In OnReadData you add the child nodes programmatically, don't you?

    If so, you can also set which child node is expanded. The following example adds five new child nodes and programmatically expands the 4th one. You can modify the logical expression to check against the value stored in your database.

    protected void OnReadData(object sender, NodeLoadEventArgs e)
    {
        for (int i = 1; i < 6; i++)
        {
            Node treeNode = new Node();
            treeNode.Text = i.ToString();
            treeNode.NodeID = i.ToString();
            treeNode.Expanded = (i == 4);
            e.Nodes.Add(treeNode);
        }
    
        e.Nodes.Add(treeNode);
    }

Similar Threads

  1. Replies: 9
    Last Post: Jan 30, 2015, 11:46 AM
  2. Replies: 1
    Last Post: Apr 02, 2013, 5:50 AM
  3. [CLOSED] Expanding Tree Nodes in Behind Code
    By taylorjp2000 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 11, 2012, 6:00 PM
  4. Replies: 0
    Last Post: Dec 19, 2011, 12:11 AM
  5. Replies: 1
    Last Post: May 04, 2010, 9:54 AM

Posting Permissions