3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 19 Oct 2012, 12:32 PM
Hi Sigma,
Try the following code snippet to achieve your scenario.
ASPX:
JS:
Regards,
Shinu.
Try the following code snippet to achieve your scenario.
ASPX:
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Show"
OnClientClicked
=
"OnClientClicked"
>
</
telerik:RadButton
>
<
telerik:RadContextMenu
ID
=
"RadContextMenu1"
runat
=
"server"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"RadMenuItem1"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
Text
=
"RadMenuItem2"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
Text
=
"RadMenuItem3"
>
</
telerik:RadMenuItem
>
</
Items
>
</
telerik:RadContextMenu
>
JS:
<script type=
"text/javascript"
>
function
OnClientClicked(sender, args) {
var
contextMenu = $find(
"<%= RadContextMenu1.ClientID %>"
);
contextMenu.show(args);
}
</script>
Regards,
Shinu.
0
Sam
Top achievements
Rank 1
answered on 09 Nov 2017, 05:01 PM
I had to add this:
<script type=
"text/javascript"
>
function
OnClientClicked(sender, args) {
var
contextMenu = $find(
"<%= RadContextMenu1.ClientID %>"
);
contextMenu.show(args);
$telerik.cancelRawEvent(event);
}
</script>
I'm attaching to a div. The above code shows the context menu...
How do I hide the menu when user clicks elsewhere or when user blurs off the context menu?
0
Hi Sam,
You can call the client-side hide() method of the RadContextMenu when you want it to hide: https://docs.telerik.com/devtools/aspnet-ajax/controls/menu/client-side-programming/objects/radmenu-and-radcontextmenu-objects#radcontextmenu-specific-api.
To this end you can attach event handlers to the page (e.g., click for the body, mouseover for the body) and check whether the event originates from the menu, in a fashion similar to this thread: https://www.telerik.com/forums/how-to-show-hide-menu-on-mouseover-and-mouseout.
Regards,
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.