|
322 | 322 |
|
323 | 323 | // Handle table initialization event
|
324 | 324 | $table.on('init.dt.dtCheckboxes', function(){
|
325 |
| - self.onDataTablesInit(); |
| 325 | + // Use delay to handle initialization event |
| 326 | + // because certain extensions (FixedColumns) are initialized |
| 327 | + // only when initialization event is triggered. |
| 328 | + setTimeout(function(){ |
| 329 | + self.onDataTablesInit(); |
| 330 | + }, 0); |
326 | 331 | });
|
327 | 332 |
|
328 | 333 | // Handle state saving event
|
|
462 | 467 |
|
463 | 468 | $.each(self.s.columns, function(index, colIdx){
|
464 | 469 | self.updateSelectAll(colIdx);
|
465 |
| - }); |
| 470 | + }); |
466 | 471 | },
|
467 | 472 |
|
468 | 473 | // Handles DataTables Ajax request completion event
|
|
565 | 570 | // Update table state
|
566 | 571 | updateState: function(){
|
567 | 572 | var self = this;
|
| 573 | + var dt = self.s.dt; |
| 574 | + var ctx = self.s.ctx; |
568 | 575 |
|
569 | 576 | self.updateStateCheckboxes({ page: 'all', search: 'none' });
|
570 | 577 |
|
571 |
| - $.each(self.s.columns, function(index, colIdx){ |
572 |
| - self.updateSelectAll(colIdx); |
573 |
| - }); |
| 578 | + // If FixedColumns extension is enabled |
| 579 | + if(ctx._oFixedColumns){ |
| 580 | + // Use delay to let FixedColumns construct the header |
| 581 | + // before we update the "Select all" checkbox |
| 582 | + setTimeout(function(){ |
| 583 | + // For every column where checkboxes are enabled |
| 584 | + $.each(self.s.columns, function(index, colIdx){ |
| 585 | + self.updateSelectAll(colIdx); |
| 586 | + }); |
| 587 | + }, 0); |
| 588 | + } |
574 | 589 | },
|
575 | 590 |
|
576 | 591 | // Updates state of multiple checkboxes
|
|
919 | 934 | if(ctx._oFixedColumns){
|
920 | 935 | var leftCols = ctx._oFixedColumns.s.iLeftColumns;
|
921 | 936 | var rightCols = ctx.aoColumns.length - ctx._oFixedColumns.s.iRightColumns - 1;
|
| 937 | + |
922 | 938 | if (colIdx < leftCols || colIdx > rightCols){
|
| 939 | + // Update the data shown in the fixed column |
923 | 940 | dt.fixedColumns().update();
|
| 941 | + |
| 942 | + // Use delay to let FixedColumns construct the header |
| 943 | + // before we update the "Select all" checkbox |
| 944 | + setTimeout(function(){ |
| 945 | + // For every column where checkboxes are enabled |
| 946 | + $.each(self.s.columns, function(index, colIdx){ |
| 947 | + self.updateSelectAll(colIdx); |
| 948 | + }); |
| 949 | + }, 0); |
924 | 950 | }
|
925 | 951 | }
|
926 | 952 | }
|
|
1039 | 1065 | ctx.checkboxes.updateSelect(rowsSelectableIdx, state);
|
1040 | 1066 | }
|
1041 | 1067 |
|
1042 |
| - // If FixedColumns extension is enabled |
1043 |
| - if(ctx._oFixedColumns){ |
1044 |
| - // Use timeout to let FixedColumns construct the header |
1045 |
| - // before we update the "Select all" checkbox |
1046 |
| - setTimeout(function(){ ctx.checkboxes.updateSelectAll(colIdx); }, 0); |
1047 |
| - |
1048 |
| - } else { |
1049 |
| - ctx.checkboxes.updateSelectAll(colIdx); |
1050 |
| - } |
| 1068 | + ctx.checkboxes.updateSelectAll(colIdx); |
1051 | 1069 |
|
1052 | 1070 | ctx.checkboxes.updateFixedColumn(colIdx);
|
1053 | 1071 | }
|
|
1073 | 1091 | ctx.checkboxes.updateSelect(rowIdx, state);
|
1074 | 1092 | }
|
1075 | 1093 |
|
1076 |
| - // If FixedColumns extension is enabled |
1077 |
| - if(ctx._oFixedColumns){ |
1078 |
| - // Use timeout to let FixedColumns construct the header |
1079 |
| - // before we update the "Select all" checkbox |
1080 |
| - setTimeout(function(){ ctx.checkboxes.updateSelectAll(colIdx); }, 0); |
1081 |
| - |
1082 |
| - } else { |
1083 |
| - ctx.checkboxes.updateSelectAll(colIdx); |
1084 |
| - } |
| 1094 | + ctx.checkboxes.updateSelectAll(colIdx); |
1085 | 1095 |
|
1086 | 1096 | ctx.checkboxes.updateFixedColumn(colIdx);
|
1087 | 1097 | }
|
|
0 commit comments