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

Reverse Loop through Nodes

2 Answers 122 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 2
Tina asked on 15 Oct 2014, 07:48 PM
I need to reverse loop through the parent nodes of a node to get the text of each node.  So if my node structure is parent->child1->child2 I need to go loop child2->child1->parent.  Any suggestions?

2 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 20 Oct 2014, 07:08 AM
Hello,

Please review the following articles, which explain in detail the Client API of the TreeView control, and how you can use it to traverse the tree in whichever manner you need:
http://www.telerik.com/help/aspnet-ajax/treeview-client-basics.html
http://www.telerik.com/help/aspnet-ajax/treeview-client-objects-radtreenode.html

Regards,
Bozhidar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tina
Top achievements
Rank 2
answered on 22 Oct 2014, 06:50 PM
I needed to do this serverside and start with a child that was checked and go in reverse through all it's parents to get the text of each one.  I accomplished this by using (vb):

dim nodeText as string = childnode.text
If Not childnode.ParentNode Is Nothing Then
    Dim parentnode As RadTreeNode = childnode.ParentNode
    Do While Not parentnode Is Nothing
          nodeText = parentnode.Text & "-" & nodeText
          parentnode = parentnode.ParentNode
    Loop
End If
Tags
TreeView
Asked by
Tina
Top achievements
Rank 2
Answers by
Bozhidar
Telerik team
Tina
Top achievements
Rank 2
Share this question
or