Rearrange items of DataView with Drag and Drop

后端 未结 1 1618
南笙
南笙 2021-01-03 15:16

I have an ExtJS DataView with following template:

相关标签:
1条回答
  • 2021-01-03 15:38

    This reminds me a bad experience I had with drag drop in ExtJS 4. Anyway, you may try this plugin. Otherwise, here is something I have tried (scroll is not handled yet) (jsFiddle) :

    new Ext.view.DragZone({
        view: view,
        ddGroup: 'test',
        dragText: 'test'
    });
    
    new Ext.view.DropZone({
        view: view,
        ddGroup: 'test',
        handleNodeDrop : function(data, record, position) {
            var view = this.view,
                store = view.getStore(),
                index, records, i, len;
            if (data.copy) {
                records = data.records;
                data.records = [];
                for (i = 0, len = records.length; i < len; i++) {
                    data.records.push(records[i].copy(records[i].getId()));
                }
            } else {
                data.view.store.remove(data.records, data.view === view);
            }
            index = store.indexOf(record);
            if (position !== 'before') {
                index++;
            }
            store.insert(index, data.records);
            view.getSelectionModel().select(data.records);
        }
    });
    
    0 讨论(0)
提交回复
热议问题