3 Ext.namespace(
'Ext.ux.dd');
12 Ext.ux.dd.GridReorderDropTarget =
function(grid, config) {
13 this.target =
new Ext.dd.DropTarget(grid.getEl(), {
14 ddGroup: grid.ddGroup ||
'GridDD'
17 ,notifyDrop:
function(dd, e, data){
19 var t = Ext.lib.Event.getTarget(e);
20 var rindex = this.grid.getView().findRowIndex(t);
21 if (rindex ===
false)
return false;
22 if (rindex == data.rowIndex)
return false;
25 if (this.gridDropTarget.fireEvent(
this.copy?
'beforerowcopy':
'beforerowmove',
this.gridDropTarget, data.rowIndex, rindex, data.selections) ===
false)
return false;
28 var ds = this.grid.getStore();
30 for(i = 0; i < data.selections.length; i++) {
31 ds.remove(ds.getById(data.selections[i].id));
34 ds.insert(rindex,data.selections);
37 var sm = this.grid.getSelectionModel();
38 if (sm) sm.selectRecords(data.selections);
41 this.gridDropTarget.fireEvent(this.copy?
'afterrowcopy':
'afterrowmove', this.gridDropTarget, data.rowIndex, rindex, data.selections);
45 ,notifyOver:
function(dd, e, data) {
46 var t = Ext.lib.Event.getTarget(e);
47 var rindex = this.grid.getView().findRowIndex(t);
48 if (rindex == data.rowIndex) rindex =
false;
50 return (rindex ===
false)? this.dropNotAllowed : this.dropAllowed;
54 Ext.apply(this.target, config);
55 if (config.listeners) Ext.apply(
this,{listeners: config.listeners});
61 ,
"beforerowcopy": true
65 Ext.ux.dd.GridReorderDropTarget.superclass.constructor.call(
this);
68 Ext.extend(Ext.ux.dd.GridReorderDropTarget, Ext.util.Observable, {
69 getTarget:
function() {
72 ,getGrid:
function() {
73 return this.target.grid;
75 ,getCopy:
function() {
76 return this.target.copy?
true:
false;
78 ,setCopy:
function(b) {
79 this.target.copy = b?
true:
false;