3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.grid.GridDragZone"></div>/**
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);
24 this.ddel = document.createElement('div');
25 this.ddel.className = 'x-grid-dd-wrap';
28 Ext.extend(Ext.grid.GridDragZone, Ext.dd.DragZone, {
31 <div id="method-Ext.grid.GridDragZone-getDragData"></div>/**
32 * <p>The provided implementation of the getDragData method which collects the data to be dragged from the GridPanel on mousedown.</p>
33 * <p>This data is available for processing in the {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
34 * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} methods of a cooperating {@link Ext.dd.DropZone DropZone}.</p>
35 * <p>The data object contains the following properties:<ul>
36 * <li><b>grid</b> : Ext.Grid.GridPanel<div class="sub-desc">The GridPanel from which the data is being dragged.</div></li>
37 * <li><b>ddel</b> : htmlElement<div class="sub-desc">An htmlElement which provides the "picture" of the data being dragged.</div></li>
38 * <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>
39 * <li><b>selections</b> : Array<div class="sub-desc">An Array of the selected Records which are being dragged from the GridPanel.</div></li>
42 getDragData : function(e){
43 var t = Ext.lib.Event.getTarget(e);
44 var rowIndex = this.view.findRowIndex(t);
45 if(rowIndex !== false){
46 var sm = this.grid.selModel;
47 if(!sm.isSelected(rowIndex) || e.hasModifier()){
48 sm.handleMouseDown(this.grid, rowIndex, e);
50 return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
55 <div id="method-Ext.grid.GridDragZone-onInitDrag"></div>/**
56 * <p>The provided implementation of the onInitDrag method. Sets the <tt>innerHTML</tt> of the drag proxy which provides the "picture"
57 * of the data being dragged.</p>
58 * <p>The <tt>innerHTML</tt> data is found by calling the owning GridPanel's {@link Ext.grid.GridPanel#getDragDropText getDragDropText}.</p>
60 onInitDrag : function(e){
61 var data = this.dragData;
62 this.ddel.innerHTML = this.grid.getDragDropText();
63 this.proxy.update(this.ddel);
67 <div id="method-Ext.grid.GridDragZone-afterRepair"></div>/**
68 * An empty immplementation. Implement this to provide behaviour after a repair of an invalid drop. An implementation might highlight
69 * the selected rows to show that they have not been dragged.
71 afterRepair : function(){
72 this.dragging = false;
75 <div id="method-Ext.grid.GridDragZone-getRepairXY"></div>/**
76 * <p>An empty implementation. Implement this to provide coordinates for the drag proxy to slide back to after an invalid drop.</p>
77 * <p>Called before a repair of an invalid drop to get the XY to animate to.</p>
78 * @param {EventObject} e The mouse up event
79 * @return {Array} The xy location (e.g. [100, 200])
81 getRepairXY : function(e, data){
85 onEndDrag : function(data, e){
89 onValidDrop : function(dd, e, id){
94 beforeInvalidDrop : function(e, id){