日期:2014-05-16  浏览次数:20320 次

Extjs gridpanel横向滚动条的显示方法

用extjs时有时左边为树形菜单,右边为tabpanel时,gridpanel里的横向滚动条显示不出来。可以在gridpanel的属性中,加入以下代码可解决这个问题。

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:      
            return;     
        }     
        if (g.autoHeight) {     
            if (this.innerHd) {     
                this.innerHd.style.width = (vw) + 'px';     
            }     
        } 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);     
    }     
} 

?