Skip to content

Commit 18dcdf2

Browse files
committed
fix(38064): fix loadFilters issue, save on localstorage
1 parent aedc84c commit 18dcdf2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Datatable/Datatable.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,21 +368,23 @@ class Datatable
368368
}
369369
370370
async function loadFilters(api) {
371-
let {filters, order} = JSON.parse(localStorage.getItem('filters_:tagId')) ?? {filters: [], order: []};
371+
let data = JSON.parse(localStorage.getItem('filters_:tagId')) ?? null;
372+
373+
if (data == null) { return; }
372374
373375
$('#:tagId .filters input, #:tagId .filters select').each(function (index, item) {
374-
$(item).val(filters[index] ?? null);
375-
api.columns(index).search(filters[index] ?? '')
376+
$(item).val(data.filters[index] ?? null);
377+
api.columns(index).search(data.filters[index] ?? '')
376378
});
377379
378-
api.order(order);
380+
api.order(data.order);
379381
380382
api.draw();
381383
}
382384
383385
async function resetFilters(api) {
384386
await localStorage.removeItem('filters_:tagId');
385-
await loadFilters(api)
387+
location.reload();
386388
}
387389
388390
function validateDate(text) {

0 commit comments

Comments
 (0)