Skip to content

Commit abbdcd0

Browse files
committed
Fix #122: Prevent empty checkboxes property in the saved state when state saving is disabled.
1 parent 5a6987e commit abbdcd0

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

js/dataTables.checkboxes.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,17 @@
411411
var self = this;
412412
var ctx = self.s.ctx;
413413

414-
// Initialize array holding checkbox state for each column
415-
data.checkboxes = [];
416-
417414
// For every column where checkboxes are enabled
418415
$.each(self.s.columns, function(index, colIdx){
419416
// If checkbox state saving is enabled
420417
if(ctx.aoColumns[colIdx].checkboxes.stateSave){
421-
// Store data associated with this plug-in
418+
// If checkboxes state hasn't been saved before
419+
if(!Object.prototype.hasOwnProperty.call(data, 'checkboxes')){
420+
// Initialize array to save checkboxes state for each column
421+
data.checkboxes = [];
422+
}
423+
424+
// Save checkboxes state
422425
data.checkboxes[colIdx] = self.s.data[colIdx];
423426
}
424427
});

0 commit comments

Comments
 (0)