How to disable checkbox? when checked

requirements need to disable checkbox when checkbox is checked

A small amount of data is paged on the client side, and the checkBy method is extended. The code is roughly as follows

related codes

BootstrapTable.prototype.newCheckBy = function (obj) {
    var checked = true;
    if (!obj.hasOwnProperty("field") || !obj.hasOwnProperty("values")) {
        return;
    }

    var that = this,
        rows = [];
    $.each(this.options.data, function (index, row) {
        if (!row.hasOwnProperty(obj.field)) {
            return false;
        }
        if ($.inArray(row[obj.field], obj.values) !== -1) {
            var $el = that.$selectItem.filter(":enabled")
                .filter(sprintf("[data-index="%s"]", index)).prop("checked", checked).prop("disabled", "disabled");
            row[that.header.stateField] = checked;
            rows.push(row);
            that.trigger(checked ? "check" : "uncheck", row, $el);
        }
    });
    this.updateSelected();
    this.trigger(checked ? "check-some" : "uncheck-some", rows);

the data on the first page can be disabled normally. The checked data on the second page can not be disabled, but it is still checked, because the data is on the second page, so $el can not get the data, but it can still be checked. I would like to ask how it is done. Thank you

Mar.28,2021

by further looking at the source code, we can see that
row [that.header.stateField] = {checked: checked, disabled: checked};
you can disable
, but another problem has been found. After switching pages to disabled and dropping checkbox, in the initRow method

item[that.header.stateField] = value === true || (!!value_ || value && value.checked);

this line of code always changes the value of checkbox to bool type, so you can no longer judge value.disable

.
Menu