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

Drag & Drop and Context Menus - Menu Won't Stay OPen

2 Answers 283 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bryan
Top achievements
Rank 1
Bryan asked on 28 Apr 2016, 07:04 PM

I am doing a drag and drop from a grid onto the treeview. All is well, events are hooking up and I am getting all the data I need to make it work. But I have one issue. After the row from the grid is dragged on to the treeview node, I display a context menu that will allow the user to select the action they would like to perform with the dragged item on the node.

I have the context menu showing in the correct place, however it quickly closes again so that the user cannot select any of the menu items.

The code which show the menu:

  function onRowDropping(sender, args) {
                if (currentNode) {
 
                    //Check to see if this is a valid drop
                    var draggedrow = args.get_draggedItems()[0];
                    var dragedentitytype = draggedrow.getDataKeyValue('EntityID');
                    var dragentityid = draggedrow.getDataKeyValue('cplID');
 
                    var dropenitytype = currentNode.get_attributes().getAttribute('EType');
                    args.set_cancel(true); //Cancel the drop, will be handled by menu item, also prevent grid from auto refreshing
 
                    var tree = $find("<%=RadTreeStandards.ClientID %>");
 
                    currentNode.set_selected(true);
 
                    tree._contextMenuNode = currentNode;
                    var menu = tree.get_contextMenus()[1];
                    menu.show(args.get_domEvent());
 
                }
                else {
                    args.set_cancel(true);
                }
            }
 
            var currentNode = null;
 
            function onNodeMouseOver(sender, args) {
                //gets the node upon mousing over the node
                currentNode = args.get_node();
            }
 
            function onNodeMouseOut(sender, args) {
                //resets the currentNode value upon mousing out
                currentNode = null;
            }

 

It seems that some event is occurring that I can't cancel that closes the menu?

Thanks,

Bryan Kowalchuk

 

 

2 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 03 May 2016, 10:57 AM
Hello Bryan,

I would suggest you to place the menu.show() call in a timeout:
setTimeout(function () {
    menu.show(args.get_domEvent());
}, 100);

This should solve the issue as the drop of the grid row itself forces the context menu to be closed. Using timeout will delay the showing after the drop event.

Regards,
Veselin Tsvetanov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Bryan
Top achievements
Rank 1
answered on 04 May 2016, 03:52 PM

Worked great, fixed the problem.

Thanks for the reply.

Bryan

Tags
TreeView
Asked by
Bryan
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Bryan
Top achievements
Rank 1
Share this question
or