Last Updated: 30 Apr 2020 08:59 by ADMIN
Created on: 21 Dec 2018 11:15
Category: Menu
Type: Feature Request
RadContextMenu to expose target control reference on the client


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.




Posted on: 30 Apr 2020 08:59

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.

Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Marin Bratanov
Posted on: 21 Dec 2018 15:30
Hi Tom,

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;

Marin Bratanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.