4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 24 Jan 2012, 01:36 PM
Hello,
Try the following javascript on OnClientClicked event of RadButton.
JS:
Thanks,
Princy.
Try the following javascript on OnClientClicked event of RadButton.
JS:
function
OnClientClicked(sender, args)
{
var
contextMenu = $find(
"<%= RadMenu1.ClientID %>"
);
contextMenu.show(args);
}
Thanks,
Princy.
0
Shukhrat Nekbaev
Top achievements
Rank 1
answered on 01 Mar 2012, 04:08 PM
Hi,
and menu:
following JS:
so when RadButton is clicked it works in IE9 and latest Chrome (haven't tried anything else yet), but doesn't work in FF, in FF it complains on event object. In RadButton's click handler I tried to pass "args" also, then in IE9 context menu is displayed in top left corner, but doesn't work in FF. Provided span trigger works good.
How do I get RadButton to trigger context menu so that it works in all browsers? Thank you!
P.S.: using latest controls (2012.1.215.40)
<
telerik:RadButton
ID
=
"btnAddComponent"
runat
=
"server"
Text
=
"Show items"
AutoPostBack
=
"false"
OnClientClicked
=
"addNewComponent"
UseSubmitBehavior
=
"false"
>
</
telerik:RadButton
>
<
span
onclick
=
"javascript:showMenu(event);"
>Test open</
span
>
and menu:
<
telerik:RadContextMenu
ID
=
"radCtxMenuNewPageComponent"
runat
=
"server"
CausesValidation
=
"true"
ValidationGroup
=
"editCurrentProjectContentElement"
OnItemClick
=
"radCtxMenuNewPageComponent_ItemClick"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Audio"
/>
<
telerik:RadMenuItem
Text
=
"Video"
/>
</
Items
>
<
CollapseAnimation
Type
=
"none"
/>
</
telerik:RadContextMenu
>
following JS:
function
addNewComponent(sender, args) {
showMenu(event);
}
function
showMenu(e) {
var
contextMenu = $find(
"<%= radCtxMenuNewPageComponent.ClientID %>"
);
if
((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) {
contextMenu.show(e);
}
$telerik.cancelRawEvent(e);
}
so when RadButton is clicked it works in IE9 and latest Chrome (haven't tried anything else yet), but doesn't work in FF, in FF it complains on event object. In RadButton's click handler I tried to pass "args" also, then in IE9 context menu is displayed in top left corner, but doesn't work in FF. Provided span trigger works good.
How do I get RadButton to trigger context menu so that it works in all browsers? Thank you!
P.S.: using latest controls (2012.1.215.40)
0
Hi,
The DOM event on clicking the RadButton is not passed to the event argument. Therefore, you cannot use this approach with RadButton. As a workaround, you can try the following:
Regards,
Peter
the Telerik team
The DOM event on clicking the RadButton is not passed to the event argument. Therefore, you cannot use this approach with RadButton. As a workaround, you can try the following:
function addNewComponent(sender, args) {
var currentLocation = $telerik.getLocation(sender.get_element());
var contextMenu = $find("<%=radCtxMenuNewPageComponent.ClientID%>");
contextMenu.showAt(currentLocation.x, currentLocation.y + 22);
}
Regards,
Peter
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Shukhrat Nekbaev
Top achievements
Rank 1
answered on 06 Mar 2012, 11:21 AM
Hi,
yeah, I've implemented similar workaround already, thanks anyway!
yeah, I've implemented similar workaround already, thanks anyway!