TreeView

3 posts, 2 answers
  1. Robert
    Robert  avatar
    68 posts
    Member since:
    Feb 2009

    Posted 12 Oct 2011 Link to this post

    I'm writing how best to expand the root node of the TreeView control by default, on the page load - either with C# or with the properties of the RadTreeView;

    rootNode.Expanded = true  - this code did not work as expected;

    Thanks in advance for any insight; 


     

     

     

     

     

     

     

     

     

     

     

     

     

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Oct 2011 Link to this post

    Hello Robert,

    You can try the following code.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
     for (int i = 0; i < RadTreeView1.Nodes.Count; i++)
      {
       this.RadTreeView1.Nodes[i].Expanded = true;
      }
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Kate
    Admin
    Kate avatar
    1898 posts

    Posted 13 Oct 2011 Link to this post

    Hello Robert,

    If you need to expand a specific node of the RadTreeView control here is a very good help article that explains how this could be achieved on the server.:Tutorial: Finding Nodes. However, if you need to expand nodes on the client-side you can refer here for more detailed explanation how it could be done (first article is for single node and the second for the collection of nodes - in the middle of the topic you can find an example how to loop through the node collection):

    http://www.telerik.com/help/aspnet-ajax/treeview-client-basics.html
    http://www.telerik.com/help/aspnet-ajax/treeview-client-objects-radtreenode.html

    Further, if you choose the client-side approach I would recommend that you use the 
    OnClientLoad event and assign an event handled as described here.
    

    Kind regards,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top