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