bootstrap-table中实现,翻页之后再返回,依然选中的情况,具体内容如下
//表格渲染完成操作
table.on('post-body.bs.table',function (e,settings,json,xhr) {
var merge_order_arr = [];
var objString = productids.val();
if(objString !== ""){
jsonObj = JSON.parse(objString);//转换为json对象
$.map(jsonObj,function (arr) {
// merge_order_arr.push.apply(merge_order_arr,arr);//合并数组
merge_order_arr = merge_order_arr.concat(arr);//合并数组
});
$.each(settings,function (i,v) {
$.each(merge_order_arr,function (index,value) {
if(v.id === parseInt(value)){
$(e.target).find('tbody tr').eq(i).find('input').click();
}
});
});
// productids.val( objString );
}
// debugger;
});
$('input[name="btSelectAll"],table tbody,input[name="btSelectItem"]').change(function () {//复选框
current_page = table.bootstrapTable('getOptions').pageNumber;
merge_order_object[current_page] = Table.api.selectedids(table);
productids.val( JSON.stringify(merge_order_object) );//转换成字符串
});