@@ -884,8 +884,8 @@ Api.register( 'checkboxes()', function () {
884884 return this ;
885885} ) ;
886886
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 ; }
889889
890890 return this . iterator ( 'column-rows' , function ( ctx , colIdx , i , j , rowsIdx ) {
891891 if ( ctx . checkboxes ) {
@@ -911,12 +911,12 @@ Api.registerPlural( 'columns().checkboxes.select()', 'column().checkboxes.select
911911
912912 cells = this . cells ( selector ) ;
913913
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 ) ;
916916
917917 // If row selection is enabled
918918 if ( ctx . aoColumns [ colIdx ] . checkboxes . selectRow ) {
919- ctx . checkboxes . updateSelect ( rowsSelectableIdx , select ) ;
919+ ctx . checkboxes . updateSelect ( rowsSelectableIdx , state ) ;
920920 }
921921
922922 // If FixedColumns extension is enabled
@@ -934,8 +934,8 @@ Api.registerPlural( 'columns().checkboxes.select()', 'column().checkboxes.select
934934 } , 1 ) ;
935935} ) ;
936936
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 ; }
939939
940940 return this . iterator ( 'cell' , function ( ctx , rowIdx , colIdx ) {
941941 if ( ctx . checkboxes ) {
@@ -944,12 +944,12 @@ Api.registerPlural( 'cells().checkboxes.select()', 'cell().checkboxes.select()',
944944
945945 // If checkbox in the cell can be checked
946946 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 ) ;
949949
950950 // If row selection is enabled
951951 if ( ctx . aoColumns [ colIdx ] . checkboxes . selectRow ) {
952- ctx . checkboxes . updateSelect ( rowIdx , select ) ;
952+ ctx . checkboxes . updateSelect ( rowIdx , state ) ;
953953 }
954954
955955 // If FixedColumns extension is enabled
@@ -980,41 +980,48 @@ Api.registerPlural( 'cells().checkboxes.enable()', 'cell().checkboxes.enable()',
980980
981981 // If checkbox should be enabled
982982 if ( state ) {
983- ctx . checkboxes . s . dataDisabled [ colIdx ] [ cellData ] = 1 ;
983+ delete ctx . checkboxes . s . dataDisabled [ colIdx ] [ cellData ] ;
984984
985985 // Otherwise, if checkbox should be disabled
986986 } else {
987- delete ctx . checkboxes . s . dataDisabled [ colIdx ] [ cellData ] ;
987+ ctx . checkboxes . s . dataDisabled [ colIdx ] [ cellData ] = 1 ;
988988 }
989989
990990 // Determine if cell node is available
991991 // (deferRender is not enabled or cell has been already created)
992992 var cellNode = cell . node ( ) ;
993993 if ( cellNode ) {
994- $ ( 'input.dt-checkboxes' , cellNode ) . prop ( 'disabled' , state ) ;
994+ $ ( 'input.dt-checkboxes' , cellNode ) . prop ( 'disabled' , ! state ) ;
995995 }
996996
997997 // If row selection is enabled
998+ // and checkbox can be checked
998999 if ( ctx . aoColumns [ colIdx ] . checkboxes . selectRow ) {
9991000 // If data is in the list
10001001 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 ) ;
10021006 }
10031007 }
10041008 }
10051009 } , 1 ) ;
10061010} ) ;
10071011
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 ) ;
10101015} ) ;
10111016
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 ) ;
10141020} ) ;
10151021
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 ) ;
10181025} ) ;
10191026
10201027Api . registerPlural ( 'columns().checkboxes.deselectAll()' , 'column().checkboxes.deselectAll()' , function ( ) {
0 commit comments