@@ -884,8 +884,8 @@ Api.register( 'checkboxes()', function () {
884
884
return this ;
885
885
} ) ;
886
886
887
- Api . registerPlural ( 'columns().checkboxes.select()' , 'column().checkboxes.select()' , function ( select ) {
888
- if ( typeof select === 'undefined' ) { select = true ; }
887
+ Api . registerPlural ( 'columns().checkboxes.select()' , 'column().checkboxes.select()' , function ( state ) {
888
+ if ( typeof state === 'undefined' ) { state = true ; }
889
889
890
890
return this . iterator ( 'column-rows' , function ( ctx , colIdx , i , j , rowsIdx ) {
891
891
if ( ctx . checkboxes ) {
@@ -911,12 +911,12 @@ Api.registerPlural( 'columns().checkboxes.select()', 'column().checkboxes.select
911
911
912
912
cells = this . cells ( selector ) ;
913
913
914
- ctx . checkboxes . updateData ( cells , colIdx , ( select ) ? true : false ) ;
915
- ctx . checkboxes . updateCheckbox ( cells , colIdx , ( select ) ? true : false ) ;
914
+ ctx . checkboxes . updateData ( cells , colIdx , state ) ;
915
+ ctx . checkboxes . updateCheckbox ( cells , colIdx , state ) ;
916
916
917
917
// If row selection is enabled
918
918
if ( ctx . aoColumns [ colIdx ] . checkboxes . selectRow ) {
919
- ctx . checkboxes . updateSelect ( rowsSelectableIdx , select ) ;
919
+ ctx . checkboxes . updateSelect ( rowsSelectableIdx , state ) ;
920
920
}
921
921
922
922
// If FixedColumns extension is enabled
@@ -934,8 +934,8 @@ Api.registerPlural( 'columns().checkboxes.select()', 'column().checkboxes.select
934
934
} , 1 ) ;
935
935
} ) ;
936
936
937
- Api . registerPlural ( 'cells().checkboxes.select()' , 'cell().checkboxes.select()' , function ( select ) {
938
- if ( typeof select === 'undefined' ) { select = true ; }
937
+ Api . registerPlural ( 'cells().checkboxes.select()' , 'cell().checkboxes.select()' , function ( state ) {
938
+ if ( typeof state === 'undefined' ) { state = true ; }
939
939
940
940
return this . iterator ( 'cell' , function ( ctx , rowIdx , colIdx ) {
941
941
if ( ctx . checkboxes ) {
@@ -944,12 +944,12 @@ Api.registerPlural( 'cells().checkboxes.select()', 'cell().checkboxes.select()',
944
944
945
945
// If checkbox in the cell can be checked
946
946
if ( ctx . checkboxes . isCellSelectable ( colIdx , cellData ) ) {
947
- ctx . checkboxes . updateData ( cells , colIdx , ( select ) ? true : false ) ;
948
- ctx . checkboxes . updateCheckbox ( cells , colIdx , ( select ) ? true : false ) ;
947
+ ctx . checkboxes . updateData ( cells , colIdx , state ) ;
948
+ ctx . checkboxes . updateCheckbox ( cells , colIdx , state ) ;
949
949
950
950
// If row selection is enabled
951
951
if ( ctx . aoColumns [ colIdx ] . checkboxes . selectRow ) {
952
- ctx . checkboxes . updateSelect ( rowIdx , select ) ;
952
+ ctx . checkboxes . updateSelect ( rowIdx , state ) ;
953
953
}
954
954
955
955
// If FixedColumns extension is enabled
@@ -980,41 +980,48 @@ Api.registerPlural( 'cells().checkboxes.enable()', 'cell().checkboxes.enable()',
980
980
981
981
// If checkbox should be enabled
982
982
if ( state ) {
983
- ctx . checkboxes . s . dataDisabled [ colIdx ] [ cellData ] = 1 ;
983
+ delete ctx . checkboxes . s . dataDisabled [ colIdx ] [ cellData ] ;
984
984
985
985
// Otherwise, if checkbox should be disabled
986
986
} else {
987
- delete ctx . checkboxes . s . dataDisabled [ colIdx ] [ cellData ] ;
987
+ ctx . checkboxes . s . dataDisabled [ colIdx ] [ cellData ] = 1 ;
988
988
}
989
989
990
990
// Determine if cell node is available
991
991
// (deferRender is not enabled or cell has been already created)
992
992
var cellNode = cell . node ( ) ;
993
993
if ( cellNode ) {
994
- $ ( 'input.dt-checkboxes' , cellNode ) . prop ( 'disabled' , state ) ;
994
+ $ ( 'input.dt-checkboxes' , cellNode ) . prop ( 'disabled' , ! state ) ;
995
995
}
996
996
997
997
// If row selection is enabled
998
+ // and checkbox can be checked
998
999
if ( ctx . aoColumns [ colIdx ] . checkboxes . selectRow ) {
999
1000
// If data is in the list
1000
1001
if ( ctx . checkboxes . s . data [ colIdx ] . hasOwnProperty ( cellData ) ) {
1001
- ctx . checkboxes . updateSelect ( rowIdx , true ) ;
1002
+ // Update selection based on current state:
1003
+ // if checkbox is enabled then select row;
1004
+ // otherwise, deselect row
1005
+ ctx . checkboxes . updateSelect ( rowIdx , state ) ;
1002
1006
}
1003
1007
}
1004
1008
}
1005
1009
} , 1 ) ;
1006
1010
} ) ;
1007
1011
1008
- Api . registerPlural ( 'cells().checkboxes.disable()' , 'cell().checkboxes.disable()' , function ( ) {
1009
- return this . checkboxes . enable ( ) ;
1012
+ Api . registerPlural ( 'cells().checkboxes.disable()' , 'cell().checkboxes.disable()' , function ( state ) {
1013
+ if ( typeof state === 'undefined' ) { state = true ; }
1014
+ return this . checkboxes . enable ( ! state ) ;
1010
1015
} ) ;
1011
1016
1012
- Api . registerPlural ( 'columns().checkboxes.deselect()' , 'column().checkboxes.deselect()' , function ( ) {
1013
- return this . checkboxes . select ( false ) ;
1017
+ Api . registerPlural ( 'columns().checkboxes.deselect()' , 'column().checkboxes.deselect()' , function ( state ) {
1018
+ if ( typeof state === 'undefined' ) { state = true ; }
1019
+ return this . checkboxes . select ( ! state ) ;
1014
1020
} ) ;
1015
1021
1016
- Api . registerPlural ( 'cells().checkboxes.deselect()' , 'cell().checkboxes.deselect()' , function ( ) {
1017
- return this . checkboxes . select ( false ) ;
1022
+ Api . registerPlural ( 'cells().checkboxes.deselect()' , 'cell().checkboxes.deselect()' , function ( state ) {
1023
+ if ( typeof state === 'undefined' ) { state = true ; }
1024
+ return this . checkboxes . select ( ! state ) ;
1018
1025
} ) ;
1019
1026
1020
1027
Api . registerPlural ( 'columns().checkboxes.deselectAll()' , 'column().checkboxes.deselectAll()' , function ( ) {
0 commit comments