3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.grid.GridDragZone
11
* @extends Ext.dd.DragZone
12
* <p>A customized implementation of a {@link Ext.dd.DragZone DragZone} which provides default implementations of two of the
13
* template methods of DragZone to enable dragging of the selected rows of a GridPanel.</p>
14
* <p>A cooperating {@link Ext.dd.DropZone DropZone} must be created who's template method implementations of
15
* {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
16
* {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop}</p> are able
17
* to process the {@link #getDragData data} which is provided.
19
Ext.grid.GridDragZone = function(grid, config){
20
this.view = grid.getView();
21
Ext.grid.GridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, config);
22
if(this.view.lockedBody){
23
this.setHandleElId(Ext.id(this.view.mainBody.dom));
24
this.setOuterHandleElId(Ext.id(this.view.lockedBody.dom));
28
this.ddel = document.createElement('div');
29
this.ddel.className = 'x-grid-dd-wrap';
32
Ext.extend(Ext.grid.GridDragZone, Ext.dd.DragZone, {
36
* <p>The provided implementation of the getDragData method which collects the data to be dragged from the GridPanel on mousedown.</p>
37
* <p>This data is available for processing in the {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
38
* {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} methods of a cooperating {@link Ext.dd.DropZone DropZone}.</p>
39
* <p>The data object contains the following properties:<ul>
40
* <li><b>grid</b> : Ext.Grid.GridPanel<div class="sub-desc">The GridPanel from which the data is being dragged.</div></li>
41
* <li><b>ddel</b> : htmlElement<div class="sub-desc">An htmlElement which provides the "picture" of the data being dragged.</div></li>
42
* <li><b>rowIndex</b> : Number<div class="sub-desc">The index of the row which receieved the mousedown gesture which triggered the drag.</div></li>
43
* <li><b>selections</b> : Array<div class="sub-desc">An Array of the selected Records which are being dragged from the GridPanel.</div></li>
46
getDragData : function(e){
47
var t = Ext.lib.Event.getTarget(e);
48
var rowIndex = this.view.findRowIndex(t);
49
if(rowIndex !== false){
50
var sm = this.grid.selModel;
51
if(!sm.isSelected(rowIndex) || e.hasModifier()){
52
sm.handleMouseDown(this.grid, rowIndex, e);
54
return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
60
* <p>The provided implementation of the onInitDrag method. Sets the <tt>innerHTML</tt> of the drag proxy which provides the "picture"
61
* of the data being dragged.</p>
62
* <p>The <tt>innerHTML</tt> data is found by calling the owning GridPanel's {@link Ext.grid.GridPanel#getDragDropText getDragDropText}.</p>
64
onInitDrag : function(e){
65
var data = this.dragData;
66
this.ddel.innerHTML = this.grid.getDragDropText();
67
this.proxy.update(this.ddel);
72
* An empty immplementation. Implement this to provide behaviour after a repair of an invalid drop. An implementation might highlight
73
* the selected rows to show that they have not been dragged.
75
afterRepair : function(){
76
this.dragging = false;
80
* <p>An empty implementation. Implement this to provide coordinates for the drag proxy to slide back to after an invalid drop.</p>
81
* <p>Called before a repair of an invalid drop to get the XY to animate to.</p>
82
* @param {EventObject} e The mouse up event
83
* @return {Array} The xy location (e.g. [100, 200])
85
getRepairXY : function(e, data){
89
onEndDrag : function(data, e){
93
onValidDrop : function(dd, e, id){
98
beforeInvalidDrop : function(e, id){