This article introduces the grid drag-and-drop line instance code, the need for friends can refer to
---------------------Grid Drag-and-drop the instance code for the row to drag---------------------------------------
Copy Code code as follows:
Create the first grid
var firstgrid = new Ext.grid.GridPanel ({
Ddgroup: ' Secondgridddgroup ',//Here is the second grid of Ddgroup
Store:firstgridstore,
Enabledragdrop:true,//true indicates that the drag behavior of the selected row in the Gridpanel is initiated
...... Other properties omitted
});
Create a second grid
var secondgrid = new Ext.grid.GridPanel ({
Ddgroup: ' Firstgridddgroup ',//This is the first grid Ddgroup
Store:secondgridstore,
Enabledragdrop:true,//true indicates that the drag behavior of the selected row in the Gridpanel is initiated
...... Other properties omitted
});
//Create the first grid Ddgroup
var Firstgriddroptargetel = Firstgrid.getview (). El.dom.childnodes[0].childnodes[1];
var firstgriddroptarget = new Ext.dd.DropTarget (Firstgriddroptargetel, {
ddgroup : ' Firstgridddgroup ',//Ddgroup same as the second grid
copy : True,
Notifydrop: function (Ddsource, E, data) {
function addrow (record, index, allitems) {
var found Item = 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 a second grid of Ddgroup
var Secondgriddroptargetel = Secondgrid.getview (). El.dom.childnodes[0].childnodes[1];
var secondgriddroptarget = new Ext.dd.DropTarget (secondgriddroptargetel,{
Ddgroup: ' Secondgridddgroup ',// Same as the first grid Ddgroup
copy : True,
Notifydrop: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);
}
});