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