Skip to content

Commit b63c477

Browse files
committed
Fix #50: Make disabled checkboxes not affect indeterminate state of "Select all" control
1 parent c07aeb2 commit b63c477

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

js/dataTables.checkboxes.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ Checkboxes.prototype = {
629629

630630
// Indicate that state of "Select all" control has been changed
631631
$(ctrl).data('is-changed', true);
632-
632+
633633
dt.column(colIdx, {
634634
page: (
635635
(ctx.aoColumns[colIdx].checkboxes && ctx.aoColumns[colIdx].checkboxes.selectAllPages)
@@ -685,9 +685,17 @@ Checkboxes.prototype = {
685685
var $checkboxesSelectAll = $('.dt-checkboxes-select-all[data-col="' + colIdx + '"] input[type="checkbox"]', $tableContainer);
686686

687687
var countChecked = 0;
688+
var countDisabled = 0;
688689
var cellsData = cells.data();
689690
$.each(cellsData, function(index, cellData){
690-
if(self.s.data[colIdx].hasOwnProperty(cellData)){ countChecked++; }
691+
// If checkbox is not disabled
692+
if(self.isCellSelectable(colIdx, cellData)){
693+
if(self.s.data[colIdx].hasOwnProperty(cellData)){ countChecked++; }
694+
695+
// Otherwise, if checkbox is disabled
696+
} else {
697+
countDisabled++;
698+
}
691699
});
692700

693701
// If FixedHeader is enabled in this instance
@@ -702,12 +710,12 @@ Checkboxes.prototype = {
702710
var isIndeterminate;
703711

704712
// If none of the checkboxes are checked
705-
if (countChecked === 0) {
713+
if (countChecked === 0){
706714
isSelected = false;
707715
isIndeterminate = false;
708716

709717
// If all of the checkboxes are checked
710-
} else if (countChecked === cellsData.length) {
718+
} else if ((countChecked + countDisabled) === cellsData.length){
711719
isSelected = true;
712720
isIndeterminate = false;
713721

0 commit comments

Comments
 (0)