Hide context menu after calling set_cancel

2 posts, 0 answers
  1. rpritchard77
    rpritchard77 avatar
    2 posts
    Member since:
    Nov 2006

    Posted 10 Oct 2008 Link to this post

    Hello,

    Some menu item click events I handle on the client and some on the server:

     

    <telerik:RadTreeView ID="fileTree"
    runat="server"
    OnContextMenuItemClick="fileTree_ContextMenuItemClick"
    OnClientContextMenuItemClicking="clientContextMenuItemClicking">

    When I call eventArgs.set_cancel(true); on a client side event handler that I do not want to be processed on the server,  the context menu does not disappear.  Is there a way to hide the menu or should I be doing something different?

     

     

     

       function clientContextMenuItemClicking(sender, eventArgs)
       {
        var node = eventArgs.get_node();
        var item = eventArgs.get_menuItem();
        var tree = node.get_treeView();

        if (item.get_value() == "DeleteFile")
         if (!confirm("Are you sure you want to delete this file?\n\n This cannot be undone."))
          eventArgs.set_cancel(true);
       } 

    Many thanks! Ryan

     

  2. Erjan Gavalji
    Admin
    Erjan Gavalji avatar
    1455 posts

    Posted 13 Oct 2008 Link to this post

    Hi Ryan,

    No, you are not doing anything wrong. Actually the cancellation of the event stops any processing of the default action. You can easily hide the menu by calling args.get_menuItem().get_menu().hide();

    I hope this helps.

    Kind regards,
    Erjan Gavalji
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top