Skip to content

Commit 9101254

Browse files
committed
Corrected issue with server-side processing mode
1 parent 6d54fff commit 9101254

File tree

2 files changed

+30
-35
lines changed

2 files changed

+30
-35
lines changed

js/dataTables.checkboxes.js

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*! Checkboxes 1.2.5-dev
1+
/*! Checkboxes 1.2.5
22
* Copyright (c) Gyrocode (www.gyrocode.com)
33
* License: MIT License
44
*/
55

66
/**
77
* @summary Checkboxes
88
* @description Checkboxes extension for jQuery DataTables
9-
* @version 1.2.5-dev
9+
* @version 1.2.5
1010
* @file dataTables.checkboxes.js
1111
* @author Gyrocode (http://www.gyrocode.com/projects/jquery-datatables-checkboxes/)
1212
* @contact http://www.gyrocode.com/contacts
@@ -265,35 +265,6 @@ Checkboxes.prototype = {
265265
});
266266
}
267267

268-
// Handle Ajax request completion event
269-
$table.on('xhr.dt', function ( e, settings, json, xhr ) {
270-
// Retrieve stored state
271-
var state = dt.state.loaded();
272-
273-
$.each(self.s.columns, function(index, colIdx){
274-
// Clear data
275-
self.s.data[colIdx] = {};
276-
277-
// If state is loaded and contains data for this column
278-
if(state && state.checkboxes && state.checkboxes.hasOwnProperty(colIdx)){
279-
// Load previous state
280-
self.s.data[colIdx] = state.checkboxes[colIdx];
281-
}
282-
});
283-
284-
// If state saving is enabled
285-
if(ctx.oFeatures.bStateSave){
286-
// If server-side processing mode is not enabled
287-
// NOTE: Needed to avoid duplicate call to updateCheckboxes() in onDraw()
288-
if(!ctx.oFeatures.bServerSide){
289-
// Update table state on next redraw
290-
$table.one('draw.dt.dtCheckboxes', function(e){
291-
self.updateState();
292-
});
293-
}
294-
}
295-
});
296-
297268
// Handle table draw event
298269
$table.on('draw.dt.dtCheckboxes', function(e){
299270
self.onDraw(e);
@@ -345,7 +316,32 @@ Checkboxes.prototype = {
345316
// If server-side processing mode is not enabled
346317
// NOTE: Needed to avoid duplicate call to updateCheckboxes() in onDraw()
347318
if(!ctx.oFeatures.bServerSide){
319+
348320
self.updateState();
321+
322+
// Handle Ajax request completion event
323+
// NOTE: Needed to update table state
324+
// if table is reloaded via ajax.reload() API method
325+
$table.on('xhr.dt', function ( e, settings, json, xhr ) {
326+
// Retrieve stored state
327+
var state = dt.state.loaded();
328+
329+
$.each(self.s.columns, function(index, colIdx){
330+
// Clear data
331+
self.s.data[colIdx] = {};
332+
333+
// If state is loaded and contains data for this column
334+
if(state && state.checkboxes && state.checkboxes.hasOwnProperty(colIdx)){
335+
// Load previous state
336+
self.s.data[colIdx] = state.checkboxes[colIdx];
337+
}
338+
});
339+
340+
// Update table state on next redraw
341+
$table.one('draw.dt.dtCheckboxes', function(e){
342+
self.updateState();
343+
});
344+
});
349345
}
350346

351347
// Handle state saving event
@@ -505,7 +501,6 @@ Checkboxes.prototype = {
505501
var ctx = self.s.ctx;
506502

507503
// Enumerate all cells
508-
var dataSeen = {};
509504
dt.cells('tr', self.s.columns, opts).every(function(cellRow, cellCol){
510505
// Get cell data
511506
var cellData = this.data();
@@ -980,7 +975,7 @@ Api.registerPlural( 'columns().checkboxes.selected()', 'column().checkboxes.sele
980975
* @name Checkboxes.version
981976
* @static
982977
*/
983-
Checkboxes.version = '1.2.5-dev';
978+
Checkboxes.version = '1.2.5';
984979

985980

986981

0 commit comments

Comments
 (0)