3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.grid.GridDragZone"></div>/**
15 * @class Ext.grid.GridDragZone
16 * @extends Ext.dd.DragZone
17 * <p>A customized implementation of a {@link Ext.dd.DragZone DragZone} which provides default implementations of two of the
18 * template methods of DragZone to enable dragging of the selected rows of a GridPanel.</p>
19 * <p>A cooperating {@link Ext.dd.DropZone DropZone} must be created who's template method implementations of
20 * {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
21 * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop}</p> are able
22 * to process the {@link #getDragData data} which is provided.
24 Ext.grid.GridDragZone = function(grid, config){
25 this.view = grid.getView();
26 Ext.grid.GridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, config);
29 this.ddel = document.createElement('div');
30 this.ddel.className = 'x-grid-dd-wrap';
33 Ext.extend(Ext.grid.GridDragZone, Ext.dd.DragZone, {
36 <div id="method-Ext.grid.GridDragZone-getDragData"></div>/**
37 * <p>The provided implementation of the getDragData method which collects the data to be dragged from the GridPanel on mousedown.</p>
38 * <p>This data is available for processing in the {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
39 * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} methods of a cooperating {@link Ext.dd.DropZone DropZone}.</p>
40 * <p>The data object contains the following properties:<ul>
41 * <li><b>grid</b> : Ext.Grid.GridPanel<div class="sub-desc">The GridPanel from which the data is being dragged.</div></li>
42 * <li><b>ddel</b> : htmlElement<div class="sub-desc">An htmlElement which provides the "picture" of the data being dragged.</div></li>
43 * <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>
44 * <li><b>selections</b> : Array<div class="sub-desc">An Array of the selected Records which are being dragged from the GridPanel.</div></li>
47 getDragData : function(e){
48 var t = Ext.lib.Event.getTarget(e);
49 var rowIndex = this.view.findRowIndex(t);
50 if(rowIndex !== false){
51 var sm = this.grid.selModel;
52 if(!sm.isSelected(rowIndex) || e.hasModifier()){
53 sm.handleMouseDown(this.grid, rowIndex, e);
55 return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
60 <div id="method-Ext.grid.GridDragZone-onInitDrag"></div>/**
61 * <p>The provided implementation of the onInitDrag method. Sets the <tt>innerHTML</tt> of the drag proxy which provides the "picture"
62 * of the data being dragged.</p>
63 * <p>The <tt>innerHTML</tt> data is found by calling the owning GridPanel's {@link Ext.grid.GridPanel#getDragDropText getDragDropText}.</p>
65 onInitDrag : function(e){
66 var data = this.dragData;
67 this.ddel.innerHTML = this.grid.getDragDropText();
68 this.proxy.update(this.ddel);
72 <div id="method-Ext.grid.GridDragZone-afterRepair"></div>/**
73 * An empty immplementation. Implement this to provide behaviour after a repair of an invalid drop. An implementation might highlight
74 * the selected rows to show that they have not been dragged.
76 afterRepair : function(){
77 this.dragging = false;
80 <div id="method-Ext.grid.GridDragZone-getRepairXY"></div>/**
81 * <p>An empty implementation. Implement this to provide coordinates for the drag proxy to slide back to after an invalid drop.</p>
82 * <p>Called before a repair of an invalid drop to get the XY to animate to.</p>
83 * @param {EventObject} e The mouse up event
84 * @return {Array} The xy location (e.g. [100, 200])
86 getRepairXY : function(e, data){
90 onEndDrag : function(data, e){
94 onValidDrop : function(dd, e, id){
99 beforeInvalidDrop : function(e, id){