ColumnSplitDD.js
上传用户:shuoshiled
上传日期:2018-01-28
资源大小:10124k
文件大小:2k
源码类别:

中间件编程

开发平台:

JavaScript

  1. /*!
  2.  * Ext JS Library 3.0.0
  3.  * Copyright(c) 2006-2009 Ext JS, LLC
  4.  * licensing@extjs.com
  5.  * http://www.extjs.com/license
  6.  */
  7. // private
  8. // This is a support class used internally by the Grid components
  9. Ext.grid.SplitDragZone = function(grid, hd, hd2){
  10.     this.grid = grid;
  11.     this.view = grid.getView();
  12.     this.proxy = this.view.resizeProxy;
  13.     Ext.grid.SplitDragZone.superclass.constructor.call(this, hd,
  14.         "gridSplitters" + this.grid.getGridEl().id, {
  15.         dragElId : Ext.id(this.proxy.dom), resizeFrame:false
  16.     });
  17.     this.setHandleElId(Ext.id(hd));
  18.     this.setOuterHandleElId(Ext.id(hd2));
  19.     this.scroll = false;
  20. };
  21. Ext.extend(Ext.grid.SplitDragZone, Ext.dd.DDProxy, {
  22.     fly: Ext.Element.fly,
  23.     b4StartDrag : function(x, y){
  24.         this.view.headersDisabled = true;
  25.         this.proxy.setHeight(this.view.mainWrap.getHeight());
  26.         var w = this.cm.getColumnWidth(this.cellIndex);
  27.         var minw = Math.max(w-this.grid.minColumnWidth, 0);
  28.         this.resetConstraints();
  29.         this.setXConstraint(minw, 1000);
  30.         this.setYConstraint(0, 0);
  31.         this.minX = x - minw;
  32.         this.maxX = x + 1000;
  33.         this.startPos = x;
  34.         Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
  35.     },
  36.     handleMouseDown : function(e){
  37.         var ev = Ext.EventObject.setEvent(e);
  38.         var t = this.fly(ev.getTarget());
  39.         if(t.hasClass("x-grid-split")){
  40.             this.cellIndex = this.view.getCellIndex(t.dom);
  41.             this.split = t.dom;
  42.             this.cm = this.grid.colModel;
  43.             if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
  44.                 Ext.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
  45.             }
  46.         }
  47.     },
  48.     endDrag : function(e){
  49.         this.view.headersDisabled = false;
  50.         var endX = Math.max(this.minX, Ext.lib.Event.getPageX(e));
  51.         var diff = endX - this.startPos;
  52.         this.view.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
  53.     },
  54.     autoOffset : function(){
  55.         this.setDelta(0,0);
  56.     }
  57. });