Hi,
I use the RadContextMenu control (ajax). When I right-click a control to show the menu, the OnClientShowing or On ClientItemClicked events are fired.
Within this, I can get the html element that has been clicked, but what I really need is a reference to the actual control that was clicked. For example, I have a checkbox on my page and the user can right-click the text on the checkbox, OR the check-box itself. This makes it really tough to determine what the actual control was that was clicked (in this case, the RadCheckBox).
I thought it would be a cool idea to be able to get this control as part of the args for the event.
Tom.
Hi Folks,
The <telerik:ContextMenuDocumentTarget> option identifies the document element of the Web page as a target. That is, the context menu appears wherever the user right-clicks on the page. This tag uses no additional attributes.
For more info check out this article RadContextMenu Object.
Regards,
Rumen
Progress Telerik
I have made this enhancement request public (link) so we can gauge the public interest in it.
I must note, however, that the context menu ties to an HTML element (or set of them) and not necessarily to an IScriptControl client object. Thus, in the most common case, the menu does not know what the parent control is, and should not know.
Nevertheless, you can relatively easy traverse the DOM to get a reference to the closest IScriptControl object. Here's an example that relies on the fact that all our controls render a CSS class that looks like "Rad<ControlName>":
var
$ = $ || $telerik.$;
function
OnClientShowing(sender, args) {
var
target = args.get_targetElement();
var
telerikControl = $(target).closest(
"[class^='Rad']"
)[0].control;
}
Regards,
Marin Bratanov
Progress Telerik