This is a migrated thread and some comments may be shown as answers.

TreeView

2 Answers 23 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 12 Oct 2011, 05:17 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 13 Oct 2011, 04:52 AM
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.
0
Accepted
Kate
Telerik team
answered on 13 Oct 2011, 11:25 AM
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
Tags
TreeView
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Kate
Telerik team
Share this question
or