@@ -627,6 +627,9 @@ Checkboxes.prototype = {
627
627
colIdx = dt . column ( $th ) . index ( ) ;
628
628
}
629
629
630
+ // Indicate that state of "Select all" control has been changed
631
+ $ ( ctrl ) . data ( 'is-changed' , true ) ;
632
+
630
633
dt . column ( colIdx , {
631
634
page : (
632
635
( ctx . aoColumns [ colIdx ] . checkboxes && ctx . aoColumns [ colIdx ] . checkboxes . selectAllPages )
@@ -714,14 +717,24 @@ Checkboxes.prototype = {
714
717
isIndeterminate = true ;
715
718
}
716
719
717
- $checkboxesSelectAll . prop ( {
718
- 'checked' : isSelected ,
719
- 'indeterminate' : isIndeterminate
720
- } ) ;
720
+ var isChanged = $checkboxesSelectAll . data ( 'is-changed' ) ;
721
+ var isSelectedNow = $checkboxesSelectAll . prop ( 'checked' ) ;
722
+ var isIndeterminateNow = $checkboxesSelectAll . prop ( 'indeterminate' ) ;
723
+
724
+ // If state of "Select all" control has been changed
725
+ if ( isChanged || isSelectedNow !== isSelected || isIndeterminateNow !== isIndeterminate ) {
726
+ // Reset "Select all" control state flag
727
+ $checkboxesSelectAll . data ( 'is-changed' , false ) ;
721
728
722
- // If selectAllCallback is a function
723
- if ( $ . isFunction ( ctx . aoColumns [ colIdx ] . checkboxes . selectAllCallback ) ) {
724
- ctx . aoColumns [ colIdx ] . checkboxes . selectAllCallback ( $checkboxesSelectAll . closest ( 'th' ) . get ( 0 ) , isSelected , isIndeterminate ) ;
729
+ $checkboxesSelectAll . prop ( {
730
+ 'checked' : isSelected ,
731
+ 'indeterminate' : isIndeterminate
732
+ } ) ;
733
+
734
+ // If selectAllCallback is a function
735
+ if ( $ . isFunction ( ctx . aoColumns [ colIdx ] . checkboxes . selectAllCallback ) ) {
736
+ ctx . aoColumns [ colIdx ] . checkboxes . selectAllCallback ( $checkboxesSelectAll . closest ( 'th' ) . get ( 0 ) , isSelected , isIndeterminate ) ;
737
+ }
725
738
}
726
739
}
727
740
} ,
0 commit comments