【实例简介】
【实例截图】
【核心代码】
Fixed ColumnsFixed Columns
var $table = $('#table');
$(function () {
buildTable($table, 20, 20);
$('#fixedNumber').change(function () {
buildTable($table, 20, 20);
});
});
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',
pagination: true,
//height: 300,
pageSize: 10,
pageList: [10, 25, 50, 100],
fixedColumns: true,
fixedNumber: $('#fixedNumber').val(),
onClickCell:function (field,value,row,element){
console.log(field);
console.log(value);
console.log(row);
console.log(element);
}
});
}