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