Upgrade to ExtJS 3.0.3 - Released 10/11/2009
[extjs.git] / docs / source / GridDD.html
1 <html>
2 <head>
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>
6 </head>
7 <body  onload="prettyPrint();">
8     <pre class="prettyprint lang-js">/*!
9  * Ext JS Library 3.0.3
10  * Copyright(c) 2006-2009 Ext JS, LLC
11  * licensing@extjs.com
12  * http://www.extjs.com/license
13  */
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.
23  */
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);
27     this.scroll = false;
28     this.grid = grid;
29     this.ddel = document.createElement('div');
30     this.ddel.className = 'x-grid-dd-wrap';
31 };
32
33 Ext.extend(Ext.grid.GridDragZone, Ext.dd.DragZone, {
34     ddGroup : "GridDD",
35
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>
45      * </ul></p>
46      */
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);
54             }
55             return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
56         }
57         return false;
58     },
59
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>
64      */
65     onInitDrag : function(e){
66         var data = this.dragData;
67         this.ddel.innerHTML = this.grid.getDragDropText();
68         this.proxy.update(this.ddel);
69         // fire start drag?
70     },
71
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.
75      */
76     afterRepair : function(){
77         this.dragging = false;
78     },
79
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])
85      */
86     getRepairXY : function(e, data){
87         return false;
88     },
89
90     onEndDrag : function(data, e){
91         // fire end drag?
92     },
93
94     onValidDrop : function(dd, e, id){
95         // fire drag drop?
96         this.hideProxy();
97     },
98
99     beforeInvalidDrop : function(e, id){
100
101     }
102 });
103 </pre>
104 </body>
105 </html>