ColumnSplitDD.js
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:2k
源码类别:

JavaScript

开发平台:

JavaScript

  1. /*!
  2.  * Ext JS Library 3.1.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 = Ext.extend(Ext.dd.DDProxy, {
  10.     fly: Ext.Element.fly,
  11.     
  12.     constructor : function(grid, hd, hd2){
  13.         this.grid = grid;
  14.         this.view = grid.getView();
  15.         this.proxy = this.view.resizeProxy;
  16.         Ext.grid.SplitDragZone.superclass.constructor.call(this, hd,
  17.             "gridSplitters" + this.grid.getGridEl().id, {
  18.             dragElId : Ext.id(this.proxy.dom), resizeFrame:false
  19.         });
  20.         this.setHandleElId(Ext.id(hd));
  21.         this.setOuterHandleElId(Ext.id(hd2));
  22.         this.scroll = false;
  23.     },
  24.     b4StartDrag : function(x, y){
  25.         this.view.headersDisabled = true;
  26.         this.proxy.setHeight(this.view.mainWrap.getHeight());
  27.         var w = this.cm.getColumnWidth(this.cellIndex);
  28.         var minw = Math.max(w-this.grid.minColumnWidth, 0);
  29.         this.resetConstraints();
  30.         this.setXConstraint(minw, 1000);
  31.         this.setYConstraint(0, 0);
  32.         this.minX = x - minw;
  33.         this.maxX = x + 1000;
  34.         this.startPos = x;
  35.         Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
  36.     },
  37.     handleMouseDown : function(e){
  38.         var ev = Ext.EventObject.setEvent(e);
  39.         var t = this.fly(ev.getTarget());
  40.         if(t.hasClass("x-grid-split")){
  41.             this.cellIndex = this.view.getCellIndex(t.dom);
  42.             this.split = t.dom;
  43.             this.cm = this.grid.colModel;
  44.             if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
  45.                 Ext.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
  46.             }
  47.         }
  48.     },
  49.     endDrag : function(e){
  50.         this.view.headersDisabled = false;
  51.         var endX = Math.max(this.minX, Ext.lib.Event.getPageX(e));
  52.         var diff = endX - this.startPos;
  53.         this.view.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
  54.     },
  55.     autoOffset : function(){
  56.         this.setDelta(0,0);
  57.     }
  58. });