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

Accessing treeNode attributes in javascript

1 Answer 253 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 13 May 2009, 05:02 PM
Is there a doc anywhere that lists all the treeNode get methods? Basically I need to pull an attribute out of the selected node and I have been unable to get to it. The only things that seem to work are get_text() and get_value(). Neither of which help me.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 May 2009, 12:37 PM
Hello James,

You can use the get_attributes() method of RadTreeNode object to get the collection of all custom attributes set to the Node. See the example shown below:

ASPX:
 
<telerik:RadTreeView ID="RadTreeView1"  runat="server" OnClientNodeClicked="onNodeClicked">  
   <Nodes> 
       <telerik:RadTreeNode runat="server" Text="BMW" CategoryOf="Car">  
       </telerik:RadTreeNode> 
       <telerik:RadTreeNode runat="server" Text="Red" CategoryOf="Color">  
       </telerik:RadTreeNode> 
       <telerik:RadTreeNode runat="server" Text="Mango" CategoryOf="Fruit">  
       </telerik:RadTreeNode> 
   </Nodes> 
</telerik:RadTreeView> 

JavaScript:
 
<script language="javascript" type="text/javascript">  
 function onNodeClicked(sender, args)  
 {  
   var node = args.get_node();  
   alert(node.get_attributes().getAttribute("CategoryOf"));  
   //you can also set attributes, like:  
   //node.get_attributes().setAttribute("CategoryOf");  
 }  
</script> 

Go through the following link which lists the most important functions of the RadTreeNode object.
RadTreeNode

Thanks,
Princy.
Tags
TreeView
Asked by
James
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or