1、在渲染表格处加上responseHandler属性
$table=$('#forkliftList').bootstrapTable({
method: "post",
url: 'forklift/queryForkliftListByTopOfficeIdAndOfficeId.do',
cache: false,
pagination: true,
dataField: 'rows',//rows
singleSelect: false,
clickToSelect: true,
responseHandler:responseHandler,
queryParams: function (data) {
data['plateNumber'] = $("#_plateNumber").val();
data['topOfficeId'] = "${topOfficeId}";
data['officeId'] = "${officeId}";
return data;
},
columns: [
{checkbox: true,formatter : stateFormatter},
{field: 'plateNumber', title: $.i18n.prop('PlateNumber'), width: 80, align: 'center'},
{field: 'brand', title: $.i18n.prop('Brand'), width: 80, align: 'center'},
{field: 'model', title: $.i18n.prop('Model'), width: 80, align: 'center'},
{field: 'topOfficeName', title: $.i18n.prop('Company'), width: 80, align: 'center'},
{field: 'officeName', title: $.i18n.prop('Department'), width: 80, align: 'center'},
{field: 'boxId', title: $.i18n.prop('DeviceNo'), width: 80, align: 'center'}
],
onLoadSuccess:function(data){
$("#forkliftList").bootstrapTable("checkBy", {field:"checked", values:[true]});
}
});
2、添加responseHandler方法
//表格分页之前处理多选框数据
function responseHandler(res) {
$.each(res.rows, function (i, row) {
row.checkStatus = $.inArray(row.id, selectionIds) != -1; //判断当前行的数据id是否存在与选中的数组,存在则将多选框状态变为true
});
return res;
}
3、get到翻页的值
var selectionIds = []; //保存选中ids
for (var i = 0; i < selectionIds.length; i++) {
forkliftIdList.push(selectionIds[i]);
data['forkliftIdList'] = forkliftIdList.join(',');
}