|
67 | 67 | this.s = {
|
68 | 68 | dt: new DataTable.Api( settings ),
|
69 | 69 | columns: [],
|
70 |
| - data: [], |
71 |
| - dataDisabled: [], |
| 70 | + data: {}, |
| 71 | + dataDisabled: {}, |
72 | 72 | ignoreSelect: false
|
73 | 73 | };
|
74 | 74 |
|
|
607 | 607 | var isCellSelectable = self.isCellSelectable(colIdx, cellData);
|
608 | 608 |
|
609 | 609 | // If checkbox is checked
|
610 |
| - if(ctx.checkboxes.s.data[colIdx].hasOwnProperty(cellData)){ |
| 610 | + if( |
| 611 | + Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.data, colIdx) |
| 612 | + && Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.data[colIdx], cellData) |
| 613 | + ) { |
611 | 614 | // If row selection is enabled
|
612 | 615 | // and checkbox can be checked
|
613 | 616 | if(ctx.aoColumns[colIdx].checkboxes.selectRow && isCellSelectable){
|
|
671 | 674 | var cellData = cell.data();
|
672 | 675 |
|
673 | 676 | // Determine whether data is in the list
|
674 |
| - var hasData = self.s.data[colIdx].hasOwnProperty(cellData); |
| 677 | + var hasData = ( |
| 678 | + Object.prototype.hasOwnProperty.call(self.s.data, colIdx) |
| 679 | + && Object.prototype.hasOwnProperty.call(self.s.data[colIdx], cellData) |
| 680 | + ); |
675 | 681 |
|
676 | 682 | // If state of the checkbox needs to be updated
|
677 | 683 | if(hasData !== ctrl.checked){
|
|
768 | 774 | $.each(cellsData, function(index, cellData){
|
769 | 775 | // If checkbox is not disabled
|
770 | 776 | if(self.isCellSelectable(colIdx, cellData)){
|
771 |
| - if(self.s.data[colIdx].hasOwnProperty(cellData)){ countChecked++; } |
| 777 | + if( |
| 778 | + Object.prototype.hasOwnProperty.call(self.s.data, colIdx) |
| 779 | + && Object.prototype.hasOwnProperty.call(self.s.data[colIdx], cellData) |
| 780 | + ) { |
| 781 | + countChecked++; |
| 782 | + } |
772 | 783 |
|
773 | 784 | // Otherwise, if checkbox is disabled
|
774 | 785 | } else {
|
|
846 | 857 | // Count number of selected rows
|
847 | 858 | var countRows = 0;
|
848 | 859 | for (var cellData in ctx.checkboxes.s.data[colIdx]){
|
849 |
| - if (ctx.checkboxes.s.data[colIdx].hasOwnProperty(cellData)){ |
| 860 | + if( |
| 861 | + Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.data, colIdx) |
| 862 | + && Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.data[colIdx], cellData) |
| 863 | + ) { |
850 | 864 | countRows++;
|
851 | 865 | }
|
852 | 866 | }
|
|
884 | 898 | var ctx = self.s.ctx;
|
885 | 899 |
|
886 | 900 | // If data is in the list of disabled elements
|
887 |
| - if(ctx.checkboxes.s.dataDisabled[colIdx].hasOwnProperty(cellData)){ |
| 901 | + if( |
| 902 | + Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.dataDisabled, colIdx) |
| 903 | + && Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.dataDisabled[colIdx], cellData) |
| 904 | + ) { |
888 | 905 | return false;
|
889 | 906 |
|
890 | 907 | // Otherwise, if checkbox can be selected
|
|
1136 | 1153 | // and checkbox can be checked
|
1137 | 1154 | if(ctx.aoColumns[colIdx].checkboxes.selectRow){
|
1138 | 1155 | // If data is in the list
|
1139 |
| - if(ctx.checkboxes.s.data[colIdx].hasOwnProperty(cellData)){ |
| 1156 | + if( |
| 1157 | + Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.data, colIdx) |
| 1158 | + && Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.data[colIdx], cellData) |
| 1159 | + ) { |
1140 | 1160 | // Update selection based on current state:
|
1141 | 1161 | // if checkbox is enabled then select row;
|
1142 | 1162 | // otherwise, deselect row
|
|
1204 | 1224 | // Enumerate all cells data
|
1205 | 1225 | $.each(cellsData, function(index, cellData){
|
1206 | 1226 | // If checkbox is checked
|
1207 |
| - if(ctx.checkboxes.s.data[colIdx].hasOwnProperty(cellData)){ |
| 1227 | + if( |
| 1228 | + Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.data, colIdx) |
| 1229 | + && Object.prototype.hasOwnProperty.call(ctx.checkboxes.s.data[colIdx], cellData) |
| 1230 | + ) { |
1208 | 1231 | // If checkbox in the cell can be selected
|
1209 | 1232 | if(ctx.checkboxes.isCellSelectable(colIdx, cellData)){
|
1210 | 1233 | data.push(cellData);
|
|
0 commit comments