This is a migrated thread and some comments may be shown as answers.

ContextMenu set target

1 Answer 113 Views
Menu
This is a migrated thread and some comments may be shown as answers.
TheCroc
Top achievements
Rank 1
TheCroc asked on 02 Jul 2009, 02:42 PM
Hi

In Q2 2007 we are using the following code to dynamically set the target and open a ContextMenu on client click of a regular html control.

var menu = window["<%= PropertiesMenu.ClientID %>"]; 
if (menu) 
  menu.SetContextElementID(obj.id); 

We're refactoring to use Q3 2008 and can see from the documentation that we should be using "set_targets" instead but this raises an error. Can you provide an eaxmple of how to use set_targets?

1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 03 Jul 2009, 12:28 PM
Hello there,

Unfortunately this functionality is not available out of the box. However, we have prepared a workaround for you. Put the following lines right after the ScriptManager declaration:

 
<script type="text/javascript"
        Telerik.Web.UI.RadContextMenu.prototype.addTargetElement = function(element) { 
            if(element){ 
                this._targetElements[this._targetElements.length] = element; 
                var eventName = $telerik.isOpera ? "mousedown" : "contextmenu"
                $addHandler(element, eventName, this._elementContextMenu);   
            } 
        } 
      
        function pageLoad() { 
            var menu = $find("RadContextMenu1"); 
            menu.addTargetElement($get("div1")); 
        }   
    </script> 

You can find sample project attached as well.

Since we think this is a good addition, we have decided to implement the feature for the future version of the RadContextMenu. In fact, it will be available forth from the next internal build.

In addition I have updated your Telerik points.

Best regards,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Menu
Asked by
TheCroc
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or