Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / ColumnSplitDD.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">// private
9 // This is a support class used internally by the Grid components
10 Ext.grid.SplitDragZone = function(grid, hd, hd2){
11     this.grid = grid;
12     this.view = grid.getView();
13     this.proxy = this.view.resizeProxy;
14     Ext.grid.SplitDragZone.superclass.constructor.call(this, hd,
15         "gridSplitters" + this.grid.getGridEl().id, {
16         dragElId : Ext.id(this.proxy.dom), resizeFrame:false
17     });
18     this.setHandleElId(Ext.id(hd));
19     this.setOuterHandleElId(Ext.id(hd2));
20     this.scroll = false;
21 };
22 Ext.extend(Ext.grid.SplitDragZone, Ext.dd.DDProxy, {
23     fly: Ext.Element.fly,
24
25     b4StartDrag : function(x, y){
26         this.view.headersDisabled = true;
27         this.proxy.setHeight(this.view.mainWrap.getHeight());
28         var w = this.cm.getColumnWidth(this.cellIndex);
29         var minw = Math.max(w-this.grid.minColumnWidth, 0);
30         this.resetConstraints();
31         this.setXConstraint(minw, 1000);
32         this.setYConstraint(0, 0);
33         this.minX = x - minw;
34         this.maxX = x + 1000;
35         this.startPos = x;
36         Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
37     },
38
39
40     handleMouseDown : function(e){
41         var ev = Ext.EventObject.setEvent(e);
42         var t = this.fly(ev.getTarget());
43         if(t.hasClass("x-grid-split")){
44             this.cellIndex = this.view.getCellIndex(t.dom);
45             this.split = t.dom;
46             this.cm = this.grid.colModel;
47             if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
48                 Ext.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
49             }
50         }
51     },
52
53     endDrag : function(e){
54         this.view.headersDisabled = false;
55         var endX = Math.max(this.minX, Ext.lib.Event.getPageX(e));
56         var diff = endX - this.startPos;
57         this.view.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
58     },
59
60     autoOffset : function(){
61         this.setDelta(0,0);
62     }
63 });</pre>    \r
64 </body>\r
65 </html>