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