[CLOSED] DragEnd event in TreeViewDragDrop plugin

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] DragEnd event in TreeViewDragDrop plugin

    Hallo,
    I have TabPanel with two tabs - A and B.
    Each tab contains TreePanel with TreeViewDragDrop plugin defined and I want to drag nodes from tab A and drop on tab B.
    When I drag an item from tab A over tab B button, I activate tab B to get the drop zone available.

    For this purpose, I created variable isDraggingStarted which I set to true on Drag event of tab A (to indicate that dragging started and is in a process). This flag is then tested on tab's B MouseOver and if 'true' I activate this tab to allow drop. After the drop, I reset this flag back to false (to avoid tab B activation every time the mouse is over tab B button).

    Everything works well except the situation when a user does not finish dragging (e.g. drop item outside drop area) => isDraggingStarted remains true. To handle this I need to fire DragEnd event and reset flag here. How do I force this event to fire?

    Second option is to use some kind of system level Ext flag which indicates that dragging is in process (and get rid of my own flag). Is there any indicator I can use for that purpose?

    Besides many other things I tried also DragTracker which fires DragEnd event fine but also causes drag and drop stops working.

    Can you please help me with the solution? Thank you.


    <script type="text/javascript">
    
            var _nelisRegisterTabEvents = function (tabPanel) {
                tabPanel.items.each(function (tab) {
                    var index = tabPanel.items.indexOf(tab);
                    tabPanel.getTabBar().items.get(index).on('mouseover', function (event) { if (isDraggingStarted) Ext.getCmp("_nelisTabPanelId").setActiveTab("B"); }, this);
                });
            }
    
    </script>
    
    // TAB A
    public Ext.Net.Container.Builder RenderAsTree()
    {
        Container container = new Container()
        {
            ID = "_nelisMenuTreeId",
            Layout = "Accordion"
        };
        container.LayoutConfig.Add(new AccordionLayoutConfig() { Animate = true });
    
        Node root = new Node();
    
        TreePanel moduleA = new TreePanel() {
            Title = rootItem.Text,
            RootVisible = false,
            Scrollable = ScrollableOption.Both,
            UseArrows = true,
            Border = false
        };
        moduleA.Listeners.ItemClick.Fn = "Nelis.Main.onMenuClick";
        moduleA.Root.Add(root);
    
        TreeView tv = new TreeView();
        tv.Plugins.Add(new TreeViewDragDrop() {
            ContainerScroll = true,
            Copy = true,
            EnableDrop = false
        });
        tv.Listeners.Drag.Fn = "_nelisTreeMenu_startDrag"; // sets isDraggingStarted = true
        moduleA.View.Add(tv);
    
        container.Items.Add(moduleA);
    
        return container.ToBuilder();
    }
    
    
    // TAB B
    public Ext.Net.Container.Builder RenderUserMenu()
    {
        Container container = new Container()
        {
            ID = "_nelisMenuUserId",
            Layout = "Accordion"
    
        };
        container.LayoutConfig.Add(new Ext.Net.AccordionLayoutConfig() { Animate = true });
    
        Node root = new Node()
        {
            Text = "DROP MENU ITEM HERE",
            AllowDrag = false,
            Icon = Icon.BookmarkAdd,
            Leaf = true
        };
    
        TreePanel moduleB = new TreePanel()
        {
            Border = false,
            BufferedRenderer = false, // important! without this it crashes: [E] Ext.grid.plugin.BufferedRenderer.scrollTo(): Unknown record passed to BufferedRenderer#scrollTo + Uncaught Error: Unknown record passed to BufferedRenderer#scrollTo
            UseArrows = true
        };
        moduleB.Listeners.ItemClick.Fn = "Nelis.Main.onMenuClick";
        moduleB.Listeners.AfterRender.Handler = "Ext.dd.DragDropManager.useCache = false;"; // important! without this drag & drop works only once for the very first time
        moduleB.Root.Add(root);
    
        TreeView tv = new TreeView();
        tv.Plugins.Add(new TreeViewDragDrop() {
            ContainerScroll = true,
            AllowContainerDrops = true,
            EnableDrop = true
        });
        tv.Listeners.BeforeDrop.Fn = "_nelisTreeMenu_beforeDrop"; // if canceled sets isDraggingStarted = false
        tv.Listeners.Drop.Fn = "_nelisTreeMenu_Drop"; // sets isDraggingStarted = false
        moduleB.View.Add(tv);
    
        container.Items.Add(moduleB);
    
        return container.ToBuilder();
    }
    Last edited by fabricio.murta; Mar 21, 2017 at 9:16 PM.

Similar Threads

  1. Replies: 3
    Last Post: Jul 22, 2014, 1:55 PM
  2. [CLOSED] DragDrop in treepanel using TreeViewDragDrop plugin
    By pawangyanwali in forum 2.x Legacy Premium Help
    Replies: 14
    Last Post: Apr 29, 2013, 4:36 AM
  3. Replies: 4
    Last Post: Apr 24, 2013, 6:35 AM
  4. TreeViewDragDrop With restriction in before drop
    By shunilkarki in forum 2.x Help
    Replies: 5
    Last Post: Apr 16, 2013, 9:50 AM
  5. [CLOSED] TreeViewDragDrop plugin on over event
    By Leonid_Veriga in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 21, 2012, 6:39 AM

Posting Permissions