mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-30 18:17:00 +08:00
Bug #18867: Fixed multiple issues with yii\grid\CheckboxColumn
- "check all" checkbox not being checked on page load when all data row checkboxes are initially checked - clicking checkboxes triggered "change" event for other checkboxes that do not change their state - "check all" checkbox not being checked when disabled checkboxes are present and clicking last non-checked data row checkbox
This commit is contained in:
@ -188,16 +188,17 @@
|
||||
if (!options.multiple || !options.checkAll) {
|
||||
return;
|
||||
}
|
||||
var checkAll = "#" + id + " input[name='" + options.checkAll + "']";
|
||||
var inputs = options['class'] ? "input." + options['class'] : "input[name='" + options.name + "']";
|
||||
var inputsEnabled = "#" + id + " " + inputs + ":enabled";
|
||||
initEventHandler($grid, 'checkAllRows', 'click.yiiGridView', checkAll, function () {
|
||||
$grid.find(inputs + ":enabled").prop('checked', this.checked).change();
|
||||
var checkAllInput = "input[name='" + options.checkAll + "']";
|
||||
var inputs = (options['class'] ? "input." + options['class'] : "input[name='" + options.name + "']") + ":enabled";
|
||||
initEventHandler($grid, 'checkAllRows', 'click.yiiGridView', "#" + id + " " + checkAllInput, function () {
|
||||
$grid.find(inputs + (this.checked ? ":not(:checked)" : ":checked")).prop('checked', this.checked).change();
|
||||
});
|
||||
initEventHandler($grid, 'checkRow', 'click.yiiGridView', inputsEnabled, function () {
|
||||
var handler = function () {
|
||||
var all = $grid.find(inputs).length == $grid.find(inputs + ":checked").length;
|
||||
$grid.find("input[name='" + options.checkAll + "']").prop('checked', all).change();
|
||||
});
|
||||
$grid.find(checkAllInput + (all ? ":not(:checked)" : ":checked")).prop('checked', all).change();
|
||||
};
|
||||
initEventHandler($grid, 'checkRow', 'click.yiiGridView', "#" + id + " " + inputs, handler);
|
||||
handler(); // Ensure "check all" checkbox is checked on page load if all data row checkboxes are initially checked.
|
||||
},
|
||||
|
||||
getSelectedRows: function () {
|
||||
|
||||
Reference in New Issue
Block a user