How to get treenode value using contextmenu onclientcontextmenushowing

2 posts, 1 answers
  1. Michael Thornton
    Michael Thornton avatar
    4 posts
    Member since:
    Aug 2009

    Posted 18 Aug 2009 Link to this post

    I am having the hardest time trying to get the value of a rad treenode when i'm using the radcontextmenu.  When I right click the item, I'm using the OnClientContextMenuShowing event to be able to capture this information in javascript.  How can I get the value of the treenode that the context menu is associated with.  Also, if I view source on the page with the rad treeview, I can't see the value stored anywhere in the html like I would if I set the value of a ASP.Net treeview control.  Any help would be appreciated as this should be a relatively easy and common scenario.  I don't want to use server side options just to be clear.  Thanks in advance for your help.
  2. Answer
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Aug 2009 Link to this post

    Hello Michael,

    Try the following approach in order to get RadTreeNode client object in OnClientContextMenuShowing event handler.

    <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientContextMenuShowing="OnClientContextMenuShowing">  
            <telerik:RadTreeViewContextMenu ID="ContextMenu">  
                    <telerik:RadMenuItem Text="Copy" Value="Copy">  
                    <telerik:RadMenuItem Text="Edit" Value="Edit">  
            <telerik:RadTreeNode runat="server" Text="Root RadTreeNode1" Value="Value1">  
             . . .  

    <script type="text/javascript">  
    function OnClientContextMenuShowing(sender, args)  
        alert("Clicked node text : "+ args.get_node().get_text()); // Get the node text  
        alert("Clicked node value : "+args.get_node().get_value()); // Get the node value  

Back to Top