Confused about RadTreeView.Nodes collection...

4 posts, 1 answers
  1. J
    J avatar
    143 posts
    Member since:
    Jun 2006

    Posted 08 Jun 2009 Link to this post

    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
  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 08 Jun 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. J
    J avatar
    143 posts
    Member since:
    Jun 2006

    Posted 08 Jun 2009 Link to this post

    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.
  5. neily
    neily avatar
    13 posts
    Member since:
    Jun 2007

    Posted 01 Oct 2009 Link to this post

    thanks fro posting you finished code J - this has just helped me out of a similar problem
    Neil
Back to Top