Context menu item click on tree node double click

4 posts, 0 answers
  1. Geoffrey Smith
    Geoffrey Smith avatar
    2 posts
    Member since:
    Aug 2008

    Posted 14 Aug 2009 Link to this post

    Hello,

    My tree view has got nodes with context menu item "Edit node". I'd like to trigger the same event (simulate clicking on the context menu item) by double clicking on the node in the tree.

    Is it possible? Please help ...

    Regards,
    Kamil - Folding Space
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 14 Aug 2009 Link to this post

    Hi Kamil,

    Currently this is not possible. Double clicking a node can enter edit mode if this is enabled and will fire the OnClientDoubleClick client-side event. You can subscribe to that event and execute the code which is currently run when the user clicks the "Edit" item.

    Regards,
    Albert,
    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.
  3. Geoffrey Smith
    Geoffrey Smith avatar
    2 posts
    Member since:
    Aug 2008

    Posted 14 Aug 2009 Link to this post

    Hi Albert,

    Can you please post a quick example how to subscribe or even trigger to the context menu item click event so I can trigger it somewhere else?

    I assume it will be something like:

    function RadTree_DoubleClick(sender, eventArgs) {
        var node = eventArgs.get_node();    
        node.get_contextMenu().get_allItems()[0].click();                     
    }

    Thank you,
    Kamil
  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 14 Aug 2009 Link to this post

    Hi Geoffrey Smith,

    Here is a sample implementation:

                function onDoubleClick(sender, args) {
                    var node = args.get_node();
                    var contextMenu = sender.get_contextMenus()[0];
                   
                    sender._contextMenuNode = node;
                   
                    var item = contextMenu.findItemByText("Edit");
                   
                    item.click();
                }

    The highlighted code is important.

    All the best,
    Albert,
    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.
Back to Top