Contact Sales: +1-888-365-2779
Community & Support
Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Treeview > Show Context Menu
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Show Context Menu

Feed from this thread
  • Andrew Short avatar

    Posted on Apr 8, 2008 (permalink)

    Suppose I have another control with an event handler such as a RadComboBox.  Inside that event, based on what was selected in the combo box, I go to a treeview on the same page and find the corresponding node.  Once I find the node, I want to be able to show the context menu just as the user had right clicked on it.  I know there is
    node.show(event), and node.showAt(x, y).  When I use node.showAt(x,y), I don't think the proper event handlers are being hooked up because I get javascript errors once a menu item is chosen.  I do not understand exactly what I should pass into node.show(event).  I believe this is what I need to do, but has anyone ever seen an example of this?

  • Nick Nick admin's avatar

    Posted on Apr 9, 2008 (permalink)

    Hello Andrew Short,

    To accomplish this task you should use RadMenu as a context menu of the treeview. An example can be seen at:
    Rich Context Menu

    You can use the Show method of the menu object to show the context menu when needed.

    Hope this helps.

    Regards,
    Nick
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • Andrew Short avatar

    Posted on May 2, 2008 (permalink)

    Thanks for the reply and I have been slow to get back to this.  I already have this functionality as described in the example.  However, I have a slightly different scenario.  I have a RadComboBox with a HandleEndChanging event handler.  In that event handler, I get the reference to a specific node based on certain criteria.  Once I get the reference to that node, I want to 'simulate' a right click client side.  The menu is already associated to the node by setting the ContextMenuID on the server side when populating the treeview.  I know I can get the menu client side by node.get_contextMenu.  I haven't found a good example that demonstrates it and am having difficulty getting it to work.  I hope I explained it better.

  • Nick Nick admin's avatar

    Posted on May 5, 2008 (permalink)

    Hello Andrew Short,

    There seems to be some kind of miscommunication here as I thought that you were using the classic RadTreeView. From your last post, I have a reason to believe that you are actually talking about RadTreeView for ASP.NET Ajax (as part of Telerik.Web.UI) and its built-in menu.

    After you get the context menu you can show and hide it like:

    var menu = node.get_contextMenu();
    menu.show();
    menu.hide();

    Hope this helps.

    Best wishes,
    Nick
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • Sean avatar

    Posted on Jun 11, 2008 (permalink)

    I tried your example of:
    menu.show()

    and it gives a "Target" undefined javascript error.

    What i'm trying to accomplish:
    When the user clicks on any node within the tree I want the context menu to be displayed (so they don't have to right click.So i assigned the property
    "OnClientNodeClicked"  following JS Function (OnClientNodeClicked = "clientNodeClicked":

            function clientNodeClicked(sender, eventArgs)
            {
                var node = eventArgs.get_node();
                var menu = node.get_contextMenu();
               
                if(menu)
                    menu.show(event);
            }

    If i don't pass menu.show() any parameter it throws an error.However, if i pass it the event object when the user clicks on a Context Menu Item the events do not fire. Help would be appreciated.

  • Simon Simon admin's avatar

    Posted on Jun 16, 2008 (permalink)

    Hi Sean,

    Please try showing the Context Menu in the following manner:

            function onClientNodeClicked(sender, eventArgs) 
            { 
                var node = eventArgs.get_node(); 
                var treeView = node.get_treeView(); 
                 
                treeView.showNodeContextMenu(node, eventArgs.get_domEvent()); 
            } 

    Greetings,
    Simon
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • Sean avatar

    Posted on Jun 16, 2008 (permalink)

    Hi Simon,

    Thanks for the code sample but a context menu is not displayed. Nothing shows up. However, I now get a JavaScript error:

    "Object doesn't support this property or method."

    when I call:

    treeView.showNodeContextMenu(node, eventArgs.get_domEvent());

    I don't think the method is supported.

    Also, I can't find this function in your online documentation:
     http://www.telerik.com/help/aspnet-ajax/introduction.html

    Thanks,

    Sean

  • Simon Simon admin's avatar

    Posted on Jun 17, 2008 (permalink)

    Hi Sean,

    I have attached a simple running project which demonstrates the approach (it uses the latest trial version of RadControls for ASP.NET AJAX v2008.1 515).

    Most probably your version is older and this function has not been introduced in it, yet.

    If this is the case, please download the latest version of RadControls for ASP.NET AJAX from your Client.net account.

    Greetings,
    Simon
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • Sam avatar

    Posted on Nov 4, 2009 (permalink)

    Is it possible to expand the TreeView node context menu in this way?

     function SelectReNode(REID) {  
            var tree = $find("<%= TazaTree.ClientID %>");  
            var node = tree.findNodeByValue(REID);  
            if (node) {  
                node.select();  
                var menu = node.get_contextMenu();  
                menu.show();  
            }  
            return false;  
        }  

  • Dimitar Milushev Dimitar Milushev admin's avatar

    Posted on Nov 5, 2009 (permalink)

    Hello Sam,

    This should work as expected with the latest version of RadTreeView for ASP.NET AJAX.

    Greetings,
    Dimitar Milushev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  • Sam avatar

    Posted on Nov 5, 2009 (permalink)

    I'm running 09 Q3 release and it's giving me this error: "Error: 'target' is null or not an object"

    Thanks,
    -Sam

  • Dimitar Milushev Dimitar Milushev admin's avatar

    Posted on Nov 11, 2009 (permalink)

    Hi Sam,

    Please excuse me for misleading you. The following code should be used to show the menu:

    var pos = $telerik.getLocation(node.get_element());
    menu.showAt(pos.x, pos.y);


    Regards,
    Dimitar Milushev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  • Adrian avatar

    Posted on Dec 2, 2010 (permalink)

    Hi,

    I have this code:

    1.function ShowMenu(nodeValue) {
    2.           var tree = $find("<%= versioningUC.TreeView.ClientID %>");
    3.           var node = tree.findNodeByValue(nodeValue);
    4.           var menu = node.get_contextMenu();
    5. 
    6.           var pos = $telerik.getLocation(node.get_element());
    7.           menu.showAt(pos.x + 200, pos.y + 200);
    8.       }

    And in C#:

    1.HtmlImage img = (HtmlImage)e.Node.FindControl("imgMenu");
    2.img.Attributes["onclick"] = "ShowMenu('" + e.Node.Value + "');";

    Now, when I click image, menu shows and hide immediately. What can I do with this?

  • Adrian avatar

    Posted on Dec 2, 2010 (permalink)

    I have my answer:

     $telerik.cancelRawEvent(e); ;)

    But now.... menu doesn't fire any event. There is no PostBack. What is it this time?

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Treeview > Show Context Menu