关于Extjs gridpanel设置autoHeight:true时,横向滚动条的问题 .
使用gridpanel时我们有时需要给设置autoHeight:true,但这时如果表格的宽度大于它的容器的宽度,多余的内容就会被隐藏而不会出现横向的滚动条,费了老大劲儿才找到了解决办法,方法就是给gridpanel的option config添加如下属性:
viewConfig : {
- layout : function() {
- if (!this.mainBody) {
- return;
- }
- 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)) {
-
- 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";
<