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

Access Node FullPath from the client side

4 Answers 136 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 29 Apr 2008, 10:21 PM
Is there a way that I can get a Node's FullPath from on the client side?

Here is what I am trying to do if you see an easy way to accomplish this task.

I am using a XmlDataSource to bind a xml file to a RadTreeView.  I use some RadTreeNodeBinding's to get the tree to display properly.  I then added some custom attributes to each node....life is good.

Now I want to Edit/Insert/Delete my nodes and persist those changes back to the file (or eventually the database).

My think was to allow the user to edit some of my custom attributes on the client side then call a function that takes a collection of the attributes and a XPath to where the node in question lives.  This function would then have enough information to handle the saving.

To make this work I need to determine the FullPath on the client side or create a recursive Javascript function to create the path based on the node's parents.

Any ideas?
 

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Apr 2008, 07:37 AM
Hi Chris,

Check out the following help document link.
Getting the Nodes Full Path

Thanks
Shinu.
0
Rob
Top achievements
Rank 1
answered on 22 Jul 2009, 06:35 PM
I'm using the 7/2009 version and the client side script code provided in the answer to this original post seems to be broken as is.  According to the documentation, the parent of the root node is the Treeview and should return null.  Now, rootNode.get_parent() is returning the Treeview control instead of null and is throwing an exception on this line:

s = currentObject.get_text() + " > " + s;

Because the Treeview doesn't have a get_text() method.  Anybody else notice this?  I really need to get this working for the project I'm on.  Hopefully, there is a work around.  Compare id's?

0
Princy
Top achievements
Rank 2
answered on 23 Jul 2009, 08:22 AM
Hello Dudeman,

I tried the code given in the document with the latest version of RadControls and it works fine. Probably you must have understood it differently, so let me explain the scenario with the code. Once you mouse over the root node, what happens is explained step by step in the code below:
js:
 function onMouseOver(sender, args) // MouseOver on the root node  
   {   
       var node = args.get_node(); // You get the root node  
       var s = node.get_text(); // text of the root node  
       var currentObject = node.get_parent(); // here node.get_parent() returns treeview       
       while (currentObject != null)   
       {  
           
         if (currentObject.get_parent() != null// here get_parent() will return null for treeview, thus if condition 
           //is not satisfied  
         {    
           s = currentObject.get_text() + " > " + s; // not entered   
         }  
         currentObject = currentObject.get_parent(); // returns null which takes us out of while loop  
       }  
               
        var tbPath = s; // returns the root node text  
   }  
 
 

Hope this helps..
Princy
0
Sky
Top achievements
Rank 1
answered on 20 Jul 2010, 11:44 PM
I had the same problem. Here is how I solved:

var s = node.get_text();
var currentObject = node.get_parent();
while (currentObject != null)
{
 // get_parent() will return null when we reach the treeview
 if (currentObject.get_parent() != null)
 {
   try {
      s = currentObject.get_text() + " > " + s;
   }
   catch(err)
   {
      // Just a work around to solve get_parent() returning Treeview instead of null.
        // Do nothing here
   }
 }
 currentObject = currentObject.get_parent();
}
Tags
TreeView
Asked by
Chris
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rob
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Sky
Top achievements
Rank 1
Share this question
or