简体   繁体   中英

dynamic copy in ExtJS drag and drop

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM