Skip to content

Commit 4c778c3

Browse files
author
dtbuild
committed
8a9d1e8915198c92a96815c2b6e9c37ac4f9f7df Fix: Handle case where saved state does not include column details.
Sync to source repo @8a9d1e8915198c92a96815c2b6e9c37ac4f9f7df
1 parent 2cd015e commit 4c778c3

5 files changed

+18
-14
lines changed

datatables.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
],
1212
"src-repo": "http://github.com/DataTables/ColReorder",
1313
"last-tag": "2.0.3",
14-
"last-sync": "46aa0350ed379731e81b368be3973d6cdc27c3da"
14+
"last-sync": "8a9d1e8915198c92a96815c2b6e9c37ac4f9f7df"
1515
}

js/dataTables.colReorder.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -962,12 +962,14 @@ $(document).on('stateLoadInit.dt', function (e, settings, state) {
962962
// State's ordering indexes
963963
orderingIndexes(state.colReorder, state.order);
964964
// State's columns array - sort by restore index
965-
for (var i = 0; i < state.columns.length; i++) {
966-
state.columns[i]._cr_sort = state.colReorder[i];
965+
if (state.columns) {
966+
for (var i = 0; i < state.columns.length; i++) {
967+
state.columns[i]._cr_sort = state.colReorder[i];
968+
}
969+
state.columns.sort(function (a, b) {
970+
return a._cr_sort - b._cr_sort;
971+
});
967972
}
968-
state.columns.sort(function (a, b) {
969-
return a._cr_sort - b._cr_sort;
970-
});
971973
}
972974
}
973975
});

0 commit comments

Comments
 (0)