var grid = new Ext.grid.Grid('idGridDDTest', {
ds: ds, //TODO:datasource for you define.
cm: cm, //TODO:ColumnModel for you define.
ddGroup: 'GridDD',
ddText:'Note on drag..',
enableDragDrop : true
});
var layout = Ext.BorderLayout.create({
center: {
split:true,
margins:{left:0,top:0,right:0,bottom:0},
panels: [new Ext.GridPanel(grid)]
}
}, 'grid-panel');
// render it
grid.render();
//DD instance.
var ddrow = new Ext.dd.DropTarget(grid.getView().mainBody, {
ddGroup : 'GridDD',
copy:false,
notifyDrop : function(dd, e, data) {
var sm = grid.getSelectionModel();
var rows = sm.getSelections();
var cindex = dd.getDragData(e).rowIndex;
if (cindex == undefined || cindex < 0){
e.cancel=true;
return;
}
for (i = 0; i < rows.length; i++) {
rowData = ds.getById(rows[i].id);
if (!this.copy) {
ds.remove(ds.getById(rows[i].id)); // remove in datasource.
ds.insert(cindex, rowData); //insert record .
}
}
storeData(ds);
}