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

Hide context menu after calling set_cancel

1 Answer 99 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
rpritchard77
Top achievements
Rank 1
rpritchard77 asked on 10 Oct 2008, 04:39 PM
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

 

1 Answer, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 13 Oct 2008, 07:13 AM
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.
Tags
TreeView
Asked by
rpritchard77
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
Share this question
or