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