@@ -238,6 +238,35 @@ Checkboxes.prototype = {
238
238
} ) ;
239
239
}
240
240
241
+ // Handle Ajax request completion event
242
+ $table . on ( 'xhr.dt' , function ( e , settings , json , xhr ) {
243
+ // Retrieve stored state
244
+ var state = dt . state . loaded ( ) ;
245
+
246
+ $ . each ( self . s . columns , function ( index , colIdx ) {
247
+ // Clear data
248
+ self . s . data [ colIdx ] = { } ;
249
+
250
+ // If state is loaded and contains data for this column
251
+ if ( state && state . checkboxes && state . checkboxes . hasOwnProperty ( colIdx ) ) {
252
+ // Load previous state
253
+ self . s . data [ colIdx ] = state . checkboxes [ colIdx ] ;
254
+ }
255
+ } ) ;
256
+
257
+ // If state saving is enabled
258
+ if ( ctx . oFeatures . bStateSave ) {
259
+ // If server-side processing mode is not enabled
260
+ // NOTE: Needed to avoid duplicate call to updateCheckboxes() in onDraw()
261
+ if ( ! ctx . oFeatures . bServerSide ) {
262
+ // Update table state on next redraw
263
+ $table . one ( 'draw.dt.dtCheckboxes' , function ( e ) {
264
+ self . updateState ( ) ;
265
+ } ) ;
266
+ }
267
+ }
268
+ } ) ;
269
+
241
270
// Handle table draw event
242
271
$table . on ( 'draw.dt.dtCheckboxes' , function ( e ) {
243
272
self . onDraw ( e ) ;
@@ -289,11 +318,7 @@ Checkboxes.prototype = {
289
318
// If server-side processing mode is not enabled
290
319
// NOTE: Needed to avoid duplicate call to updateCheckboxes() in onDraw()
291
320
if ( ! ctx . oFeatures . bServerSide ) {
292
- self . updateCheckboxes ( { page : 'all' , search : 'none' } ) ;
293
-
294
- $ . each ( self . s . columns , function ( index , colIdx ) {
295
- self . updateSelectAll ( colIdx ) ;
296
- } ) ;
321
+ self . updateState ( ) ;
297
322
}
298
323
299
324
// Handle state saving event
@@ -453,6 +478,19 @@ Checkboxes.prototype = {
453
478
}
454
479
} ,
455
480
481
+ // Update table state
482
+ updateState : function ( ) {
483
+ var self = this ;
484
+ var dt = self . s . dt ;
485
+ var ctx = self . s . ctx ;
486
+
487
+ self . updateCheckboxes ( { page : 'all' , search : 'none' } ) ;
488
+
489
+ $ . each ( self . s . columns , function ( index , colIdx ) {
490
+ self . updateSelectAll ( colIdx ) ;
491
+ } ) ;
492
+ } ,
493
+
456
494
// Updates state of multiple checkboxes
457
495
updateCheckboxes : function ( opts ) {
458
496
var self = this ;
@@ -571,7 +609,7 @@ Checkboxes.prototype = {
571
609
572
610
// If server-side processing is enabled
573
611
if ( ctx . oFeatures . bServerSide ) {
574
- self . updateCheckboxes ( { page : 'current' } ) ;
612
+ self . updateCheckboxes ( { page : 'current' , search : 'none' } ) ;
575
613
}
576
614
577
615
$ . each ( self . s . columns , function ( index , colIdx ) {
0 commit comments