Bootstrap-table: bootstrap 设置高度以后,th 和 td 不对应

Created on 23 Mar 2017  ·  8Comments  ·  Source: wenzhixin/bootstrap-table

当我这样设置table的高度的时候,加载数据以后会出现变形的情况,
$table.bootstrapTable({
url:'#',
queryParams: queryParams, //参数
condition:null,
cache:false,
height:'400',
.....})
变形的情况如下 (图片上传出问题,在下面上图片了)

Uploading eg.png…
我使用的bootstrap-table版本是version: 1.11.1 ,当我把高度的参数去掉的时候,th和td对应了。这是bootstrap-table本身的bug还是怎么回事?

Most helpful comment

我在网上搜索到了一个解决方法:
bootstrap-table.js 找到 BootstrapTable.prototype.resetView
if (this.options.showHeader && this.options.height) {
this.$tableHeader.show();
//注释掉下面两行 取消表头初始化解决表头和内容不对齐问题
//this.resetHeader();
//padding += this.$header.outerHeight();
}
应用在项目中后,确实就没有这个问题了
如果你使用的是min.js,那么你得这样注释:
/*,this.resetHeader(),b+=this.$header.outerHeight()*/
希望可以帮到你

All 8 comments

eg

我在网上搜索到了一个解决方法:
bootstrap-table.js 找到 BootstrapTable.prototype.resetView
if (this.options.showHeader && this.options.height) {
this.$tableHeader.show();
//注释掉下面两行 取消表头初始化解决表头和内容不对齐问题
//this.resetHeader();
//padding += this.$header.outerHeight();
}
应用在项目中后,确实就没有这个问题了
如果你使用的是min.js,那么你得这样注释:
/*,this.resetHeader(),b+=this.$header.outerHeight()*/
希望可以帮到你

setTimeout(function() {
$('#table').bootstrapTable('resetView')
}, 100);

感谢toQhot 你发的第一个我没用,因为我本地bootstrap-table.js会出现page那个[5,10,20,..ALL]中的最后一个ALL 显示为NaN,而且翻页也出现问题,所以我使用的是bootstrap-table.min.js,使用了你推荐的第二种,结果th和td对齐了,但是除了新的问题,就是表头不固定了,会被移动,同时也感谢guohuihot你写那个延迟函数我不知道怎么放,放在$('#table').bootstrapTbale({....})这个table初始化阶段之前不行,放在之后也不行。 @toQhot @guohuihot

我这个是个另类的解决方法,我只是临时用下,不然就研究下源码,最好还是作者修复下,按resetview的作用,初始化后直接$('#table').bootstrapTable('resetView')就应该可以,不知道为什么不行,就加了个小延迟

执行resetview函数后没有了固定表头了啊,数据过多时,往上拉表头不能固定在那。。。

用最新的 develop 应该可以解决问题。

你好,我用了最新的develop后,开始的是大致对应的,但是如果列太多需要拖动,拖动后,后面的几列就又不对应了,希望作者早日解决~感谢作者的付出。 @wenzhixin

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sbellani picture sbellani  ·  4Comments

tianyaxue picture tianyaxue  ·  3Comments

lmarqs picture lmarqs  ·  3Comments

vickyrathee picture vickyrathee  ·  3Comments

rajeshbtlit picture rajeshbtlit  ·  4Comments