3 Answers, 1 is accepted
0
Hello,
The RadTreeViewContextMenu is associated with the RadTreeNodes and so are the events that make the ContextMenu appear on Node click. If you don't want the ContextMenu to show only when the user clicks on a particular node this can be done by subscribing to the OnClientContextMenuShowing event and canceling it if the user has clicked on any node, except the one you specify:
The sample code above would allow the menu to show only if the user clicks on a node with text "Search".
Regards,
Ivan Danchev
Telerik
The RadTreeViewContextMenu is associated with the RadTreeNodes and so are the events that make the ContextMenu appear on Node click. If you don't want the ContextMenu to show only when the user clicks on a particular node this can be done by subscribing to the OnClientContextMenuShowing event and canceling it if the user has clicked on any node, except the one you specify:
function
ClientContextMenuShowing(sender, eventArgs) {
var
node = eventArgs.get_node();
if
(node.get_text() !=
"Search"
) {
eventArgs.set_cancel(
true
);
}
}
<
telerik:RadTreeView
ID
=
"RadTreeView1"
runat
=
"server"
OnClientContextMenuShowing
=
"ClientContextMenuShowing"
>
The sample code above would allow the menu to show only if the user clicks on a node with text "Search".
Regards,
Ivan Danchev
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0

Igor
Top achievements
Rank 1
answered on 09 Apr 2015, 05:36 PM
Ivan, thank you for your answer.
Is there any wat to show context menu then user click on tree, but not on node?
0
Hello,
If by "tree" you mean the connection lines that link the Nodes, showing the RadContenxtMenu can be triggered by clicking on the <div> element that wraps the connection line, but clicking on the Node would open the menu as well, because the <span> element that corresponds to that Node is part of the <div> element.
Regards,
Ivan Danchev
Telerik
If by "tree" you mean the connection lines that link the Nodes, showing the RadContenxtMenu can be triggered by clicking on the <div> element that wraps the connection line, but clicking on the Node would open the menu as well, because the <span> element that corresponds to that Node is part of the <div> element.
<
telerik:RadContextMenu
ID
=
"RadContextMenu1"
runat
=
"server"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Trees"
/>
<
telerik:RadMenuItem
Text
=
"Sunset"
/>
<
telerik:RadMenuItem
Text
=
"Mountains"
/>
</
Items
>
</
telerik:RadContextMenu
>
<
script
>
var $ = $telerik.$;
$(".rtTop").click(function () {
showMenu(event);
});
$(".rtMid").click(function () {
showMenu(event);
});
$(".rtBot").click(function () {
showMenu(event);
});
function showMenu(e) {
var contextMenu = $find("<%= RadContextMenu1.ClientID %>");
contextMenu.show(e);
}
</
script
>
Regards,
Ivan Danchev
Telerik
See What's Next in App Development. Register for TelerikNEXT.