如何设置默认取消选中 bootstrap table 中的所有项目?

How to set default uncheck all items in bootstrap table?

我从这个网站遵循 bootstrap table 的属性:[http://bootstrap-table.wenzhixin.net.cn/documentation/][1]

table 看起来不错,但是当我第一次加载页面时,会检查 checkall 项目。我想默认取消勾选。

这是我的初始化代码:

var init = function (elmId) {
    try {
        var tbId = "#table-select-controlli_" + elmId;
        var h2Id = "#header_" + elmId;
        var btnId = "#btn-aggiungi_" + elmId;
        var gridId = "#grid-box_" + elmId;
        var langcode = mifid.utils.getLangCode();
        listName = $(gridId + " input")[0].value;

        //loadData();

        $(tbId).bootstrapTable(
        {
            showRefresh: true,
            showColumns: true,
            pagination: true,
            search: true,
            pageList: [10, 25, 50, 100],
            sidePagination: 'server',
            queryParams: 'getparams',
            locale: langcode,
            columns: [{
                field: fieldName.Modulo,
                title: fieldDisplay.Modulo
            }, {
                field: fieldName.Titolo,
                title: fieldDisplay.Titolo
            }, {
                field: fieldName.AmbitoControllo,
                title: fieldDisplay.AmbitoControllo
            }],
            url: _spPageContextInfo.webAbsoluteUrl + "/_vti_bin/MIFIDServices/SelectControlliService.svc/Getdata?listName=" + encodeURIComponent(listName) + "&siteurl=" + _spPageContextInfo.webAbsoluteUrl,
            cache: false,
        });
        $(h2Id).text(listName);
        RegisterEvent(tbId);
    }
    catch (e) {
        console.log(e.message);
    }
}

您可以取消选中全部或只反转选择。尝试:

全部取消勾选

$('#your-table.id').bootstrapTable('uncheckAll');

全部勾选

$('#your-table.id').bootstrapTable('checkAll');

全部反转

$('#your-table.id').bootstrapTable('checkInvert');

更新

好的,我已经在 document.reday():

里面试过了
var tbId = '#table';
$(tbId).bootstrapTable(
{
    showRefresh: true,
    showColumns: true,
    pagination: true,
    search: true,
    pageList: [10, 25, 50, 100],
    sidePagination: 'server',
    queryParams: 'getparams',
    columns: [{
        field: "ddd",
        title: "ff"
    }, {
        field: "dd",
        title: "sds"
    }, {
        field: "ffff",
        title: "ffff"
    }],
    cache: false,
});
$(tbId).bootstrapTable('checkAll');

这个工作正常。