关于Extjs gridpanel设置autoHeight:true时,横向滚动条的有关问题

关于Extjs gridpanel设置autoHeight:true时,横向滚动条的问题 .viewConfig : {layout : function() {if (!

关于Extjs gridpanel设置autoHeight:true时,横向滚动条的问题 .
viewConfig : {layout : function() {if (!this.mainBody) {return; // not rendered}var g = this.grid;var c = g.getGridEl();var csize = c.getSize(true);var vw = csize.width;if (!g.hideHeaders && (vw < 20 || csize.height < 20)) { // display:// none?return;}if (g.autoHeight) {this.el.dom.style.width = "100%";this.el.dom.style.overflow = "auto";this.el.dom.firstChild.style.overflow = "visible";this.el.dom.firstChild.style.cssFloat = "left";this.el.dom.firstChild.firstChild.style.cssFloat = "left";this.el.dom.firstChild.firstChild.nextSibling.style.cssFloat = "left";this.el.dom.firstChild.firstChild.firstChild.style.overflow = "visible";this.el.dom.firstChild.firstChild.nextSibling.style.overflow = "visible";} else {this.el.setSize(csize.width, csize.height);var hdHeight = this.mainHd.getHeight();var vh = csize.height - (hdHeight);this.scroller.setSize(vw, vh);if (this.innerHd) {this.innerHd.style.width = (vw) + 'px';}}if (this.forceFit) {if (this.lastViewWidth != vw) {this.fitColumns(false, false);this.lastViewWidth = vw;}} else {this.autoExpand();this.syncHeaderScroll();}this.onLayout(vw, vh);}} 

解决过程中遇到了好多问题,如header的背景不全,不是所有的列都能resize(已经设置了resizable:true),所以可能还有很多问题我没有发现。如果谁发现有什么问题,希望不吝赐教。

 

修改:

又发现了一个简单的方法比上边效果好多了,嘿嘿

[javascript] view plaincopyprint?
  1. viewConfig : {      layout : function() {  
  2.         if (!this.mainBody) {              return; // not rendered  
  3.         }          var g = this.grid;  
  4.         var c = g.getGridEl();          var csize = c.getSize(true);  
  5.         var vw = csize.width;          if (!g.hideHeaders && (vw < 20 || csize.height < 20)) { // display:  
  6.             // none?               return;  
  7.         }          if (g.autoHeight) {  
  8.             if (this.innerHd) {                  this.innerHd.style.width = (vw) + 'px';  
  9.             }          } else {  
  10.             this.el.setSize(csize.width, csize.height);              var hdHeight = this.mainHd.getHeight();  
  11.             var vh = csize.height - (hdHeight);              this.scroller.setSize(vw, vh);  
  12.             if (this.innerHd) {                  this.innerHd.style.width = (vw) + 'px';  
  13.             }          }  
  14.         if (this.forceFit) {              if (this.lastViewWidth != vw) {  
  15.                 this.fitColumns(false, false);                  this.lastViewWidth = vw;  
  16.             }          } else {  
  17.             this.autoExpand();              this.syncHeaderScroll();  
  18.         }          this.onLayout(vw, vh);  
  19.     }  }