百度里查的方法,记录下来,方便以后查阅
columns: [
{
checkbox: true,
formatter: function (i,row) {
if($.inArray(row.id,overAllIds)!=-1){
return{
checked:true
}
}
}
},
$('#dataTable').on('uncheck.bs.table check.bs.table check-all.bs.table uncheck-all.bs.table',function (e,rows) {
var datas=$.isArray(rows)?rows:[rows];
examine(e.type,datas);
});
var overAllIds = new Array();
function examine(type, datas) {
if (type.indexOf('uncheck') == -1) {
$.each(datas, function (i, v) {
overAllIds.indexOf(v.id)==-1?overAllIds.push(v.id):-1;
});
} else {
$.each(datas, function (i, v) {
overAllIds.splice(overAllIds.indexOf(v.id),1);
})
}
}