|
188 | 188 |
|
189 | 189 | // If state is loaded and contains data for this column
|
190 | 190 | if(state && state.checkboxes && state.checkboxes.hasOwnProperty(i)){
|
191 |
| - // Load previous state |
192 |
| - self.s.data[i] = state.checkboxes[i]; |
| 191 | + // If checkbox state saving is enabled |
| 192 | + if(ctx.aoColumns[i].checkboxes.stateSave){ |
| 193 | + // Load previous state |
| 194 | + self.s.data[i] = state.checkboxes[i]; |
| 195 | + } |
193 | 196 | }
|
194 | 197 |
|
195 | 198 | // Store column index for easy column selection later
|
|
373 | 376 | $.each(self.s.columns, function(index, colIdx){
|
374 | 377 | // If state is loaded and contains data for this column
|
375 | 378 | if(state && state.checkboxes && state.checkboxes.hasOwnProperty(colIdx)){
|
376 |
| - // Load previous state |
377 |
| - self.s.data[colIdx] = state.checkboxes[colIdx]; |
| 379 | + // If checkbox state saving is enabled |
| 380 | + if(ctx.aoColumns[colIdx].checkboxes.stateSave){ |
| 381 | + // Load previous state |
| 382 | + self.s.data[colIdx] = state.checkboxes[colIdx]; |
| 383 | + } |
378 | 384 | }
|
379 | 385 | });
|
380 | 386 |
|
|
390 | 396 | if(ctx.oFeatures.bStateSave){
|
391 | 397 | // Handle state saving event
|
392 | 398 | $table.on('stateSaveParams.dt.dtCheckboxes', function (e, settings, data){
|
393 |
| - // Store data associated with this plug-in |
394 |
| - data.checkboxes = self.s.data; |
| 399 | + // Initialize array holding checkbox state for each column |
| 400 | + data.checkboxes = []; |
| 401 | + |
| 402 | + // For every column where checkboxes are enabled |
| 403 | + $.each(self.s.columns, function(index, colIdx){ |
| 404 | + // If checkbox state saving is enabled |
| 405 | + if(ctx.aoColumns[colIdx].checkboxes.stateSave){ |
| 406 | + // Store data associated with this plug-in |
| 407 | + data.checkboxes[colIdx] = self.s.data[colIdx]; |
| 408 | + } |
| 409 | + }); |
395 | 410 | });
|
396 | 411 | }
|
397 | 412 | });
|
|
442 | 457 |
|
443 | 458 | // If state saving is enabled
|
444 | 459 | if(ctx.oFeatures.bStateSave){
|
445 |
| - // Save state |
446 |
| - dt.state.save(); |
| 460 | + // If checkbox state saving is enabled |
| 461 | + if(ctx.aoColumns[colIdx].checkboxes.stateSave){ |
| 462 | + // Save state |
| 463 | + dt.state.save(); |
| 464 | + } |
447 | 465 | }
|
448 | 466 | }
|
449 | 467 | },
|
|
871 | 889 | * @static
|
872 | 890 | */
|
873 | 891 | Checkboxes.defaults = {
|
| 892 | + /** |
| 893 | + * Enable / disable checkbox state loading/saving if state saving is enabled globally |
| 894 | + * |
| 895 | + * @type {Boolean} |
| 896 | + * @default `true` |
| 897 | + */ |
| 898 | + stateSave: true, |
| 899 | + |
874 | 900 | /**
|
875 | 901 | * Enable / disable row selection
|
876 | 902 | *
|
|
0 commit comments