bootstrapTable通过js加载到设置固定表头宽度

一、bootstrapTable通过js加载方法:

1、html中代码:

<div class="table-body">
	<table id="hlxtable" class="tab"></table>
</div>
2、js中调用


$(function() {
initTable();
initDate();
});


function initDate(){
$('.date-picker').datepicker({autoclose:true}).next().on(ace.click_event, function(){
$(this).prev().focus();
});
$('input[name=date-range-picker]').daterangepicker().prev().on(ace.click_event, function(){
$(this).next().focus();
});
}
/**
 * 初始化表格数据
 */
function initTable(){
$('#hlxtable').bootstrapTable({
method : "GET",//请求方式
pagination : true,//分页
pageSize: 10,//每页大小
   pageNumber: 1,//初始化加载第一页
pageList: [5,10,50,100,200,500],  //允许选择的每页条数
sidePagination :  "server", //由服务器端完成分页功能
queryParams: queryParams,
queryParamsType: "limit",
//search: true,
url : basePath + 'views/pages/hlx/queryHlx.htm', // 获取数据的Servlet地址
columns : [  {
field : 'boxName',
align : 'center',
title : '汇流箱名称',
width : '100'
}, {
field : 'dataTime',
align : 'center',
title : '时间',
width : '200'
}, {
field : 'totalPower',
align : 'center',
title : '总功率',
width : '100'
}  , {
field : 'dl2',
align : 'center',
title : '一',
width : '100'
}, {
field : 'dl3',
align : 'center',
title : '二',
width : '100'
}, {
field : 'dl4',
align : 'center',
title : '电流4(A)',
width : '100'
}, {
field : 'dl5',
align : 'center',
title : '三',
width : '100'
}, {
field : 'dl6',
align : 'center',
title : '四',
width : '100'
}, {
field : 'dl7',
align : 'center',
title : '五',
width : '100'
}, {
field : 'dl8',
align : 'center',
title : '六',
width : '100'
}, {
field : 'dl9',
align : 'center',
title : '七',
width : '100'
}, {
field : 'dl10',
align : 'center',
title : '八',
width : '100'
}, {
field : 'dl11',
align : 'center',
title : '九',
width : '100'
}, {
field : 'dl16',
align : 'center',
title : '电流16(A)',
width : '100'
}]
});
}

至此js实现查询已完成。

二、bootstrap-table设置表头宽度无效的解决方案

1、首先将table的表头样式设置为固定的,然后在js中添加width宽度

.tab{
    table-layout: fixed;
}


  • 8
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值