1.html页面
<div class="tableArea ">
<table class="table table-striped" id="table" data-height="600">
<!--在此处填充表格数据-->
</table>
</div>
- js方法
<script type="text/javascript">
var $table = $('#table');//绑定表格id
$(function () {
buildTable($table, 24, 24); //设置所要加载的表格列数和行数,此处为24行24列
});
function buildTable($el, cells, rows) {
var i, j, row,
columns = [],
data = [];
for (i = 0; i < cells; i++) {
columns.push({
field: 'field' + i,
title: 'Cell' + i,
sortable: true
});
}
for (i = 0; i < rows; i++) {
row = {};
for (j = 0; j < cells; j++) {
row['field' + j] = 'Row-' + i + '-' + j;
}
data.push(row);
}
$el.bootstrapTable('destroy').bootstrapTable({
columns: columns,
data: data,
search: true,
toolbar: '.toolbar',
});
}
</script>