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

Confused about RadTreeView.Nodes collection...

3 Answers 163 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
J
Top achievements
Rank 1
J asked on 08 Jun 2009, 03:32 PM
I have a DataTable that has the correct parent-child relation and fills my RadTreeView correctly.  But my question is this, after running my RadTreeView.DataBind method I will run this loop:
foreach (RadTreeNode node in radtree.Nodes)  
{  
     int intTest = node.Level;  
     node.Expanded = true;  
and I've noticed that this foreach only has a count of 1 for radtree.Nodes.  I'm a little confused as to why I can't seem to see nodes greater than Level 0 when the DataTable goes to at least a Level 4.

Is there someway to set Node.Expanded to true for nodes at Level 0-4?

Jason

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 08 Jun 2009, 03:51 PM
Hello J,

The Nodes collection contains only the root nodes of the treeview. Use the GetAllNodes() method to retrieve all nodes in the treeview.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
J
Top achievements
Rank 1
answered on 08 Jun 2009, 04:44 PM
Thanks for the reply Albert it did the job.

For anyone else here is my finished product.  Keep in mind my tree is 7 levels deep and i want to keep levels 0-3 expanded and not collapsible.

radtree.DataBind();  
 
foreach (RadTreeNode node in radtree.GetAllNodes())  
{  
    int intTest = node.Level;  
 
    if(intTest <= 3)  
    {  
        node.Expanded = true;  
        node.Enabled = false;  
        node.ExpandMode = TreeNodeExpandMode.ClientSide;  
        node.ForeColor = System.Drawing.Color.Black;  
    }  
 

This was done in the Page_Load event after setting the radtree DataSource to a DataTable.
0
neily
Top achievements
Rank 1
answered on 01 Oct 2009, 10:13 AM
thanks fro posting you finished code J - this has just helped me out of a similar problem
Neil
Tags
TreeView
Asked by
J
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
J
Top achievements
Rank 1
neily
Top achievements
Rank 1
Share this question
or