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

How to get treenode value using contextmenu onclientcontextmenushowing

1 Answer 137 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Michael Thornton
Top achievements
Rank 1
Michael Thornton asked on 19 Aug 2009, 12:57 AM
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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 Aug 2009, 06:28 AM
Hello Michael,

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

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

JavaScript:
 
<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  
}  
</script> 

Thanks,
Princy.
Tags
Menu
Asked by
Michael Thornton
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or