bootstrap-table复选框增加默认值
发表于2年前(Nov 20, 2016 12:09:48 AM)  阅读 3883  评论 0
标签: bootstrap-table checkbox formatter
bootstrap-table可以通过使用{field: 'state',checkbox: true}来设置某列显示为checkbox复选框,而我们有时需要在数据列表初始化的同时初始化checkbox的选中状态,这时可以通过增加formatter函数来实现{field: 'state',checkbox: true,formatter:stateFormatter}。
function stateFormatter(value, row, index) {
if (some coditon) {
return {
disabled: true,
checked: true
};
}
return value;
}
在stateFormatter函数里面,我们可以直接判断当前字段state的值,进行选中或者禁用操作,也可以判断行id来进行操作。