How to get all child nodes for a RadTreeView

8 posts, 0 answers
  1. Sachidanand
    Sachidanand avatar
    12 posts
    Member since:
    Jun 2011

    Posted 25 Aug 2011 Link to this post

    Hi,

    I am using a RadTreeView & the tree menu is data sourced. On the server side when I try to grab the nodes using

    foreach (RadTreeNode node in RadTreeView1.Nodes)

    This provides only the root nodes (the ones at the higher level). All of the nodes have quite few child node & subfolders (which again contain child nodes). How can I scroll thru all the nodes in the tree?

    Thank you

  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 29 Aug 2011 Link to this post

    Hello Sachidanand,

    The experienced behavior is the default one since the Nodes collection of the RadTreeView is only giving the root nodes.

    Please try the GetAllNodes method of the RadTreeView, which returns a linear list of all nodes.

    Greetings,
    Dimitar Terziev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sachidanand
    Sachidanand avatar
    12 posts
    Member since:
    Jun 2011

    Posted 29 Aug 2011 Link to this post

    Hi,

    I am trying to attach the context menu at each node dynamically.
    I am not using "GetAllNodes" but was able to get the nodes for each root node as below & calling this routine recursively.

    foreach (RadTreeNode n in nodes)


    The problem is when I am trying to set the ContextMenu option for the child nodes. It doesnt provide the method to set the ContextMenu on child nodes. Not sure if "GetAllNodes" makes any difference there.

    Can you please provide example how can I attach the context menu to child nodes for each root node. Below is the code I am currently trying & is not working. I didnt find any method which allows to set "ContectMenu" option, once inside the root node, at child node level.

    Thank you
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 01 Sep 2011 Link to this post

    Hello Sachidanand,

    Please refer to the following help article showing how to add context menus dynamically.

    Kind regards,
    Dimitar Terziev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  6. Silvia
    Silvia avatar
    7 posts
    Member since:
    Sep 2011

    Posted 18 Oct 2011 Link to this post

    Hi, 

    I need get all child nodes but in javacript, how can i do it?

    Thanks
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Oct 2011 Link to this post

    Hello Silvia,

    You can try the following to find the child nodes of each parent node. Here I tried in the NodeDoubleClick event.

    JS:
    <script type="text/javascript">
    function ClientClick(sender,args)
    {
     var i;
     for(i=0;i<sender.get_nodes().get_count();i++)
     {
      var item = sender.get_nodes().getItem(i);
      if (item.get_level() == 0)
      {
       // same logic to find the child of this parent
      }
     }
    }
    </script>

    Thanks,
    Princy.
  8. Silvia
    Silvia avatar
    7 posts
    Member since:
    Sep 2011

    Posted 19 Oct 2011 Link to this post


    Thanks for your reply your code helped me a lot :D


    But now i have other problem, i need to know if a node have child is possible in js?

    Thanks
  9. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Oct 2011 Link to this post

    Hello Silvia,

    You can try the following javascript.

    JS:
    var item = sender.get_selectedNode();
    if (item._hasChildren()==true)
    {
       //your code
    }


    Thanks,
    Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017