bootstrapTable通过js加载到设置固定表头宽度
2017-06-02 17:39
197 查看
一、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;
}
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;
}
相关文章推荐
- 通过CSS样式设置网页的最小宽度以将宽度固定为600px为例
- 对于固定表头的报表-动态设置滚动条高度、宽度的解决方法
- 通过js去预加载图片,无法正常取得图片高度和宽度的解决方法
- UIWebView 加载js内容 设置宽度自动换行
- 【Vue】项目打包的时候,build.js文件过大,可以通过设置懒加载或者按照路由分模块加载进行打包
- 转载:通过Google Ajax Libraries API加速你的js脚本的加载
- js方式固定表头
- DIV里Table的宽度设置为100%后页面出现滚动条的解决办法;DIV下移的解决办法 IE 和 FireFox 都通过
- 水滴石穿之子页面的滚动条设置 表格的固定高度宽度问题 复制带格式的文本
- 通过js在web实现Table的表头锁定
- Flex中如何通过tabWidth样式,设置TabBar每个Tab宽度
- Asp.net 利用Div固定表头+异步显示动态加载
- 通过样式表实现固定表头和列
- 工作小结(十四)-FCKeditor 通过JS设置值
- 通过样式表实现固定表头和列(ZZ)
- js中设置屏幕高度及宽度
- js固定表头补充
- DIV+CSS 布局一行两列,左列固定宽度,右列自适应宽度;设置最小宽度,窗口小的时候显示滚动条.
- 本方法只需要设置一个GridView的宽度,其它宽度不需要设置。测试环境:IE6,Firefox通过。
- 通过样式表实现固定表头和列