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

时间:2017-10-19 08:38:04

标签: jquery bootstrap-table

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

该表看起来不错,但是当我第一次加载页面时,会检查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);
    }
}

1 个答案:

答案 0 :(得分:4)

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

取消选中所有

$('#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');

这很好。