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

3 posts, 0 answers
  1. Bryan
    Bryan avatar
    2 posts
    Member since:
    Apr 2016

    Posted 28 Apr Link to this post

    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. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    287 posts

    Posted 03 May Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bryan
    Bryan avatar
    2 posts
    Member since:
    Apr 2016

    Posted 04 May Link to this post

    Worked great, fixed the problem.

    Thanks for the reply.

    Bryan

Back to Top