选中引导表中所有页面中的所有复选框

时间:2019-03-27 19:52:08

标签: javascript html5 twitter-bootstrap

我需要根据我所做的验证来选择所有页面的所有复选框,但是当前验证仅从当前页面进行,并且我需要在单击按钮时选中并保持所有页面,即使我在它们之间浏览。

示例:https://examples.bootstrap-table.com/#issues/1167.html

ja tentei utilizar o

当前JS↓

检查:函数(值,行,索引){         var _this = oSelecao;

    if (row.check == true) {
        $('#btn_editarcep' + row.pfid).attr("disabled", "disabled");
        $('#btn_editaremail' + row.pfid).attr("disabled", "disabled");
    }
    if (row.cep.length != 8) {
        row.verificaEnder = 0;
    }
    if (row.verificaFotos == 0 || _this.ValidarEmail(row.email) == false || (_this.parampixel != "True" && (row.cep.length != 8 || row.verificaEnder == 0))) {
        if (_this.ValidarEmail(row.email) == false) {
            row.verificaEmail = 0;
        }
        return {
            disabled: true
        };
    }
    if (_this.Verificaseexiste(row)) {
        return {
            checked: true
        };
    }
    return value;
}

暂定JS↓

var allPages = oSelecao.fnGetNodes();

    $('body').on('click', '#btnCheckMuniz', function () {
        if ($(this).hasClass('allChecked')) {
            $(row.check, allPages).prop('checked', false);
        } else {
            $(row.check, allPages).prop('checked', true);
        }
        $(this).toggleClass('allChecked');
    })

1 个答案:

答案 0 :(得分:0)

来自https://github.com/wenzhixin/bootstrap-table/issues/3445#issuecomment-348382740

<div id="toolbar">
    <button class="btn btn-default" id="check">Check All</button>
     <button class="btn btn-default" id="uncheck">Uncheck All</button>
</div>
<table id="table"
       ...
       data-response-handler="responseHandler">
...

<script>
var checkAll = false

$(function () {
    $('#check').click(function () {
    checkAll = true
    $('#table').bootstrapTable('checkAll')
  })
    $('#uncheck').click(function () {
    checkAll = false
    $('#table').bootstrapTable('uncheckAll')
  })
})
function responseHandler(res) {
    res.rows.forEach(function (item) {
    item.state = checkAll
  })
  return res
}
</script>