From f388ca71b08b89e940f1ffbe4afa19ae9d5e115f Mon Sep 17 00:00:00 2001 From: PowerGamer1 Date: Mon, 20 Feb 2023 17:21:00 +0200 Subject: [PATCH] Fix #18867: Check-all checkbox should be unchecked on page load when GridView have no rows (#19764) --- framework/assets/yii.gridView.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/assets/yii.gridView.js b/framework/assets/yii.gridView.js index dc7536df30..f02d4d95e9 100644 --- a/framework/assets/yii.gridView.js +++ b/framework/assets/yii.gridView.js @@ -198,7 +198,9 @@ $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. + if($grid.find(inputs).length) { + handler(); // Ensure "check all" checkbox is checked on page load if all data row checkboxes are initially checked. + } }, getSelectedRows: function () {