Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > TreeView > Accessing treeNode attributes in javascript

Not answered Accessing treeNode attributes in javascript

Feed from this thread
  • James avatar

    Posted on May 13, 2009 (permalink)

    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.

    Reply

  • Posted on May 15, 2009 (permalink)

    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > TreeView > Accessing treeNode attributes in javascript
Related resources for "Accessing treeNode attributes in javascript"

ASP.NET TreeView Features  |   Documentation   |  Demos  |  Step-by-step Tutorial  ]