Roo/grid/GridDragZone.js
[roojs1] / Roo / grid / GridDragZone.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11  
12 // private
13 // This is a support class used internally by the Grid components
14 Roo.grid.GridDragZone = function(grid, config){
15     this.view = grid.getView();
16     Roo.grid.GridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, config);
17     if(this.view.lockedBody){
18         this.setHandleElId(Roo.id(this.view.mainBody.dom));
19         this.setOuterHandleElId(Roo.id(this.view.lockedBody.dom));
20     }
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 Roo.extend(Roo.grid.GridDragZone, Roo.dd.DragZone, {
28     ddGroup : "GridDD",
29
30     getDragData : function(e){
31         var t = Roo.lib.Event.getTarget(e);
32         var rowIndex = this.view.findRowIndex(t);
33         if(rowIndex !== false){
34             var sm = this.grid.selModel;
35             
36             // if editorgrid.. 
37             if (sm.getSelectedCell && (!sm.getSelectedCell() || (sm.getSelectedCell()[0] == rowIndex) ) ) {
38                 Roo.log([ sm.getSelectedCell() ? sm.getSelectedCell()[0] : 'NO' , rowIndex ]);
39                 return false;
40             }
41             
42             //if(!sm.isSelected(rowIndex) || e.hasModifier()){
43               //  
44             //}
45             if (e.hasModifier()){
46                 sm.handleMouseDown(e, t); // non modifier buttons are handled by row select.
47             }
48             
49             Roo.log("getDragData");
50             
51             return {
52                 grid: this.grid,
53                 ddel: this.ddel,
54                 rowIndex: rowIndex,
55                 selections:sm.getSelections ? sm.getSelections() : (
56                     sm.getSelectedCell() ? [ grid.ds.getAt(sm.getSelectedCell()[0]) ] : []
57                 )
58             };
59         }
60         return false;
61     },
62
63     onInitDrag : function(e){
64         var data = this.dragData;
65         this.ddel.innerHTML = this.grid.getDragDropText();
66         this.proxy.update(this.ddel);
67         // fire start drag?
68     },
69
70     afterRepair : function(){
71         this.dragging = false;
72     },
73
74     getRepairXY : function(e, data){
75         return false;
76     },
77
78     onEndDrag : function(data, e){
79         // fire end drag?
80     },
81
82     onValidDrop : function(dd, e, id){
83         // fire drag drop?
84         this.hideProxy();
85     },
86
87     beforeInvalidDrop : function(e, id){
88
89     }
90 });