Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 689fb74

Browse files
committed
fix: allow localstorage key to be set from options
1 parent c340907 commit 689fb74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/columnmanager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ export default class ColumnManager {
279279
sortOrder: currentColumn.sortOrder
280280
}
281281
};
282-
localStorage.setItem('savedSorting', JSON.stringify(saveSorting));
282+
this.sortingKey = this.options.sortingKey ? 'sortedColumns' : `${this.options.sortingKey}::sortedColumns`;
283+
localStorage.setItem(this.sortingKey, JSON.stringify(saveSorting));
283284
}
284285

285286
removeColumn(colIndex) {
@@ -381,7 +382,8 @@ export default class ColumnManager {
381382
}
382383

383384
applySavedSortOrder() {
384-
let sortingConfig = JSON.parse(localStorage.getItem('savedSorting'));
385+
let key = this.options.sortingKey ? 'sortedColumns' : `${this.options.sortingKey}::sortedColumns`;
386+
let sortingConfig = JSON.parse(localStorage.getItem(key));
385387
if (sortingConfig) {
386388
const columnsToSort = Object.values(sortingConfig);
387389
for (let column of columnsToSort) {

0 commit comments

Comments
 (0)