bootstrapTable实现预先选中某一行

实际情况:
根据页面中,某一个DOM元素是否存在值,决定bootstrapTable表格中某一行数据是否选中,例如某一元素的值为66,那么表格中ID为66的那一行,在查看表格的时候ID为66的那一行就是已经选中的状态
代码:

    $('#Table').bootstrapTable({
        locale: 'zh-CN',
        url: "/online/alarm/list",
        method: "post",
        contentType: "application/json; charset=utf-8",
        queryParams: function(){
            return JSON.stringify({
                state: $("#value").val()
            });
        },
        pagination: true,
        search: true,
        showRefresh: true,
        showColumns: true,
        clickToSelect: true,
        pageList: [10, 25, 50, 100, 'All'],
        showExport: true,
        exportDataType: 'all',
        exportTypes: [ 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'xlsx', 'pdf'],
        columns: [
            {
            	//主要实现在这
                checkbox: true,
                formatter: function (value, row, index) {
                    if($("#linkAlarms").val()==row.id)
                        return {
                            checked : true//设置选中
                        };
                }
            },
            {
                field: 'id',
                title: 'ID',
                sortable: true
            }
       ]
       });

猜你喜欢

转载自blog.csdn.net/weixin_44219085/article/details/89923002
今日推荐