-------------------------------原文:https://blog.csdn.net/qq_15266291/article/details/54944139 ------------------------------
BootStrap-table 复选框默认选中(checkbox)
bootstrap table colums 写法
var columns = [{
field : 'checked',
checkbox : true,
formatter : stateFormatter
}]
用colums 属性设置 显示的格式
/**
* 复选按钮默认选中 格式化
*
* @param {}
* value
* @param {}
* row
* @param {}
* index
* @return {}
*/
function stateFormatter(value, row, index) {
if (row.state == true)
return {
disabled : true,//设置是否可用
checked : true//设置选中
};
return value;
}
总结
可以看出bootstrap checkbox 返回是这样的一个结果对象{
disabled : true,//设置是否可用
checked : true//设置选中
};
但是 在通过bootstrap $('#Table') .bootstrapTable('getAllSelections') 获取选中的行时候 仍然可以获得到默认加载时选中的数据
row.state 作为本条记录是否选择的标识