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

How to get all child nodes for a RadTreeView

8 Answers 1413 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Sachidanand
Top achievements
Rank 1
Sachidanand asked on 25 Aug 2011, 03:33 PM
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

8 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 29 Aug 2011, 08:00 AM
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 >>

0
Sachidanand
Top achievements
Rank 1
answered on 29 Aug 2011, 03:21 PM
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
0
Dimitar Terziev
Telerik team
answered on 01 Sep 2011, 08:13 AM
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 >>

0
Silvia
Top achievements
Rank 1
answered on 18 Oct 2011, 10:14 PM
Hi, 

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

Thanks
0
Princy
Top achievements
Rank 2
answered on 19 Oct 2011, 06:51 AM
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.
0
Silvia
Top achievements
Rank 1
answered on 20 Oct 2011, 12:15 AM

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
0
Princy
Top achievements
Rank 2
answered on 20 Oct 2011, 05:27 AM
Hello Silvia,

You can try the following javascript.

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


Thanks,
Princy.
0
raju
Top achievements
Rank 1
answered on 27 Jun 2017, 05:04 AM
Hi team,
i want to maintain the RadTreeView data during postbacks in a javascript.and i gave expandmode=3(webservice) to get a child nodes for the corresponding nodes.
Tags
Menu
Asked by
Sachidanand
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Sachidanand
Top achievements
Rank 1
Silvia
Top achievements
Rank 1
Princy
Top achievements
Rank 2
raju
Top achievements
Rank 1
Share this question
or