0
votes

I have a tree panel with treeviewdragdrop plugin. in my controller I need to ask user to select if he wants to just drop the node or to copy it.

Ext.define('App.view.admin.LevelTree', {
    extend: 'Ext.tree.Panel',
    xtype: 'leveltree',
    requires: ['Ext.tree.plugin.TreeViewDragDrop'],
    viewConfig: {
        preserveScrollOnRefresh: true,
        plugins: {
            ptype: 'treeviewdragdrop'
        }
    }

And here is my controller code:

me.getLevelTree().getView().on('drop', me.doChangeParent, me);

--

doChangeParent: function(node, data, overModel, dropPosition, eOpts) {...} 

How can I set copy: true attribute in my tree panel (in controller) based on user selection?

1

1 Answers

1
votes

You can use plugin and view configuration like this:

    viewConfig: {
                plugins: {
                    ptype: 'treeviewdragdrop'
                },
                listeners: {
                    beforedrop: function(node, data, overModel, dropPosition, dropHandlers) {
                        dropHandlers.wait = true;
                        Ext.MessageBox.confirm('Copy or move', 'If you want to copy node, press Yes', function(btn) {
                            data.copy = (btn === 'yes');
                            dropHandlers.processDrop();
                        });
                    }
                }
            },

Live example: https://fiddle.sencha.com/#fiddle/fea