|
1 |
| -/*! Checkboxes 1.1.0 |
| 1 | +/*! Checkboxes 1.1.1 |
2 | 2 | * Copyright (c) Gyrocode (www.gyrocode.com)
|
3 | 3 | * License: MIT License
|
4 | 4 | */
|
5 | 5 |
|
6 | 6 | /**
|
7 | 7 | * @summary Checkboxes
|
8 | 8 | * @description Checkboxes extension for jQuery DataTables
|
9 |
| - * @version 1.1.0 |
| 9 | + * @version 1.1.1 |
10 | 10 | * @file dataTables.checkboxes.js
|
11 | 11 | * @author Gyrocode (http://www.gyrocode.com/projects/jquery-datatables-checkboxes/)
|
12 | 12 | * @contact http://www.gyrocode.com/contacts
|
@@ -81,6 +81,9 @@ Checkboxes.prototype = {
|
81 | 81 | var hasCheckboxes = false;
|
82 | 82 | var hasCheckboxesSelectRow = false;
|
83 | 83 |
|
| 84 | + // Retrieve stored state |
| 85 | + var state = dt.state.loaded(); |
| 86 | + |
84 | 87 | for(var i = 0; i < ctx.aoColumns.length; i++){
|
85 | 88 | if (ctx.aoColumns[i].checkboxes){
|
86 | 89 | //
|
@@ -142,6 +145,12 @@ Checkboxes.prototype = {
|
142 | 145 | // Initialize array holding data for selected checkboxes
|
143 | 146 | self.s.data[i] = [];
|
144 | 147 |
|
| 148 | + // If state is loaded and contains data for this column |
| 149 | + if(state && state.checkboxes && state.checkboxes.hasOwnProperty(i)){ |
| 150 | + // Load previous state |
| 151 | + self.s.data[i] = state.checkboxes[i]; |
| 152 | + } |
| 153 | + |
145 | 154 | // Store column index for easy column selection later
|
146 | 155 | self.s.columns.push(i);
|
147 | 156 |
|
@@ -252,6 +261,15 @@ Checkboxes.prototype = {
|
252 | 261 | }
|
253 | 262 | }
|
254 | 263 | });
|
| 264 | + |
| 265 | + // If stave saving is enabled |
| 266 | + if(ctx.oFeatures.bStateSave){ |
| 267 | + // Handle state saving event |
| 268 | + dt.on('stateSaveParams.checkboxes', function (e, settings, data){ |
| 269 | + // Store data associated with this plug-in |
| 270 | + data.checkboxes = self.s.data; |
| 271 | + }); |
| 272 | + } |
255 | 273 | }
|
256 | 274 | },
|
257 | 275 |
|
@@ -317,6 +335,9 @@ Checkboxes.prototype = {
|
317 | 335 | }
|
318 | 336 | });
|
319 | 337 | }
|
| 338 | + |
| 339 | + // Save state |
| 340 | + dt.state.save(); |
320 | 341 | },
|
321 | 342 |
|
322 | 343 | // Updates row selection
|
|
0 commit comments