BootStrap-table 复选框默认选中(checkbox)

时间:2025-03-18 15:48:01
BootStrap-table 复选框默认选中(checkbox) bootstrap table colums 写法 var columns = [{ field : 'checked', checkbox : true, formatter : stateFormatter }] 2.表单值转化 如传过来的值 1换为 “正常” 2换为“错误” 在filed 那里添加函数 转换就行 row 代表该行的数据 formatter: function(value,row,index){ if(=="1") { return"正常"; }elseif (=="2") { return"冻结"; } } 用colums 属性设置 显示的格式 /** * 复选按钮默认选中 格式化 * * @param {} * value * @param {} * row * @param {} * index * @return {} */ function stateFormatter(value, row, index) { if ( == true) return { disabled : true,//设置是否可用 checked : true//设置选中 }; return value; } 总结 可以看出bootstrap checkbox 返回是这样的一个结果对象{ disabled : true,//设置是否可用 checked : true//设置选中 }; 但是 在通过bootstrap $('#Table') .bootstrapTable('getAllSelections') 获取选中的行时候 仍然可以获得到默认加载时选中的数据