This article introduces the example code of GRID drag-and-drop. If you need it, please refer to --------------------- drag-and-drop an instance code line of GRID drag-and-drop ---------------------------------------
The Code is as follows:
// Create the first GRID
Var firstGrid = new Ext. grid. GridPanel ({
DdGroup: 'secondgridddgroup', // This is the ddGroup of the second GRID.
Store: firstGridStore,
EnableDragDrop: true, // True indicates that the drag action of the row selected in the GridPanel is enabled.
...... Other attributes are omitted
});
// Create the second GRID
Var secondGrid = new Ext. grid. GridPanel ({
DdGroup: 'firstgridddgroup', // This is the ddGroup of the first grid.
Store: secondGridStore,
EnableDragDrop: true, // True indicates that the drag action of the row selected in the GridPanel is enabled.
...... Other attributes are omitted
});
// Create the ddGroup OF THE FIRST GRID
Var firstGridDropTargetEl = firstGrid. getView (). el. dom. childNodes [0]. childNodes [1];
Var firstGridDropTarget = new Ext. dd. DropTarget (firstGridDropTargetEl ,{
DdGroup: 'firstgridddgroup', // It is the same as the ddGroup of the second GRID.
Copy: true,
Yydrop: function (ddSource, e, data ){
Function addRow (record, index, allItems ){
Var foundItem = secondGridStore. find ('name', record. data. name );
If (foundItem =-1 ){
FirstGridStore. add (record );
FirstGridStore. sort ('name', 'asc ');
DdSource. grid. store. remove (record );
}
}
Ext. each (ddSource. dragData. selections, addRow );
Return (true );
}
)};
// Create the ddGroup of the second GRID
Var secondGridDropTargetEl = secondGrid. getView (). el. dom. childNodes [0]. childNodes [1];
Var secondGridDropTarget = new Ext. dd. DropTarget (secondGridDropTargetEl ,{
DdGroup: 'secondgridddgroup', // It is the same as the ddGroup of the first grid.
Copy: true,
Yydrop: function (ddSource, e, data ){
Function addRow (record, index, allItems ){
Var foundItem = secondGridStore. find ('name', record. data. name );
If (foundItem =-1 ){
SecondGridStore. add (record );
SecondGridStore. sort ('name', 'asc ');
DdSource. grid. store. remove (record );
}
}
Ext. each (ddSource. dragData. selections, addRow );
Return (true );
}
});