关于Extjs_gridpanel设置autoHeighttrue时横向滚动条的问题

摘要:
假);this.lastViewWidth=vw;//notrendered}varg=this.grid;&this.el.dom.style.soverflow=“自动”;csize.height);varhdHeight=this.mainHd.getHeight();vh);

使用gridpanel时我们有时需要给设置autoHeight:true,但这时如果表格的宽度大于它的容器的宽度,多余的内容就会被隐藏而不会出现横向的滚动条,费了老大劲儿才找到了解决办法,方法就是给gridpanel的option config添加如下属性:

Js代码
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);
}
}

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),所以可能还有很多问题我没有发现。如果谁发现有什么问题,希望不吝赐教。
修改:

Js代码
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) {
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);
}
}

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

免责声明:文章转载自《关于Extjs_gridpanel设置autoHeighttrue时横向滚动条的问题》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇ViewPager+TabLayout+Fragment刷新Fragment中的数据在postman中请求的接口有csrf怎么办下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

安卓开发实战-记账本APP(六)

记账本APP开发---终结篇 昨天的动态数字录屏奉上:在抖音上拍了一个(ps:欢迎点赞) https://v.douyin.com/poEjmG/  今天将图表的内容进行了制作,我用的是MPChart的饼状图进行制作的,将之前用户的数据进行计算,然后定义数据与具体的分类相结合。 设置不同的颜色rgb,实现饼状图的分析数据。  到此,已经将记账本APP的...

如何解决Visual Studio调试Debug很卡很慢

http://brightguo.com/make-debugging-faster-with-visual-studio/ Have you ever been frustrated by slow debugging in Visual Studio? While we work hard to bring you a fast debugging e...

深入理解javascript原型和闭包(5)——instanceof

对于值类型来说,可以用typeof判断,但typeof判断引用类型的时候返回值只有object/function,并不知道到底是哪一个。这个时候就要用到instance。例如 上图中,f1是被Foo函数创建得,但是“f1 instanceof Object”为什么是true呢? 至于为什么过会儿再说,先说下instanceof判断的规则。根据以上代码看下...

vscode开发vue项目使用eslint+prettier格式化:保存时自动执行lint进行修复(升级篇,保存时可格式化模板和css)

说明,之前的vscode开发vue项目保存时自动执行lint进行修复保存格式化,只对vue中js部分有效,template和css没有格式化,先基于此进行升级,步骤如下: 1. vue-cli创建项目时选择eslint+prettier(也可后期安装使用) 2. .eslintrc.js文件配置eslint规则(按照自己需求定义) 3. .eslintig...

maven filters 和 resource

1 filter 1.1 用途 对多个配置文件进行选择。 1.2 选择的依据 1.3 使用的方式 第一,在<resource>标签下面加<filtering>标签,并且<filtering>标签的值设置为true; 第二,添加<filters>标签,添加<filter>,并且值中使用env变量 第...

ARM 汇编的mov操作立即数的疑问

1. 因为对arm汇编有些指令还不能理解,特别是一些相似功能指令间的区别。偶然在网上搜到“faq ARM assembly”,其中描述的几个问题还是值得好好研究一下。 2. 慢慢的发现自己也不再害怕英文的文档了,耐心看至少也能懂个大概。大批经典的文章和书籍都是en文的,所以经常看英文文档是一个非常好的习惯。看看GNU的一些reference manual,...