1a596615c6259ab0023ecdc06728a5bff535528b
[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         var sm = this.grid.selModel;
34             
35         //Roo.log(rowIndex);
36         
37         if (sm.getSelectedCell) {
38             // cell selection..
39             if (!sm.getSelectedCell()) {
40                 return false;
41             }
42             if (rowIndex != sm.getSelectedCell()[0]) {
43                 return false;
44             }
45         
46         }
47         
48         if(rowIndex !== false){
49             
50             // if editorgrid.. 
51             
52             
53             //Roo.log([ sm.getSelectedCell() ? sm.getSelectedCell()[0] : 'NO' , rowIndex ]);
54                
55             //if(!sm.isSelected(rowIndex) || e.hasModifier()){
56               //  
57             //}
58             if (e.hasModifier()){
59                 sm.handleMouseDown(e, t); // non modifier buttons are handled by row select.
60             }
61             
62             Roo.log("getDragData");
63             
64             return {
65                 grid: this.grid,
66                 ddel: this.ddel,
67                 rowIndex: rowIndex,
68                 selections:sm.getSelections ? sm.getSelections() : (
69                     sm.getSelectedCell() ? [ this.grid.ds.getAt(sm.getSelectedCell()[0]) ] : []
70                 )
71             };
72         }
73         return false;
74     },
75
76     onInitDrag : function(e){
77         var data = this.dragData;
78         this.ddel.innerHTML = this.grid.getDragDropText();
79         this.proxy.update(this.ddel);
80         // fire start drag?
81     },
82
83     afterRepair : function(){
84         this.dragging = false;
85     },
86
87     getRepairXY : function(e, data){
88         return false;
89     },
90
91     onEndDrag : function(data, e){
92         // fire end drag?
93     },
94
95     onValidDrop : function(dd, e, id){
96         // fire drag drop?
97         this.hideProxy();
98     },
99
100     beforeInvalidDrop : function(e, id){
101
102     }
103 });