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

来源:互联网 发布:双11淘宝退货率 编辑:程序博客网 时间:2024/05/13 12:24

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(row.status=="1") {

                                        return"正常";  

                                }elseif (row.status=="2") {

                                         return"冻结";

                                    }

                }


用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')   获取选中的行时候 仍然可以获得到默认加载时选中的数据

0 0
原创粉丝点击