Skip to content

Commit

Permalink
fix(38064): fix loadFilters issue, save on localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
arodu committed Aug 22, 2024
1 parent aedc84c commit 18dcdf2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Datatable/Datatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,21 +368,23 @@ class Datatable
}
async function loadFilters(api) {
let {filters, order} = JSON.parse(localStorage.getItem('filters_:tagId')) ?? {filters: [], order: []};
let data = JSON.parse(localStorage.getItem('filters_:tagId')) ?? null;
if (data == null) { return; }
$('#:tagId .filters input, #:tagId .filters select').each(function (index, item) {
$(item).val(filters[index] ?? null);
api.columns(index).search(filters[index] ?? '')
$(item).val(data.filters[index] ?? null);
api.columns(index).search(data.filters[index] ?? '')
});
api.order(order);
api.order(data.order);
api.draw();
}
async function resetFilters(api) {
await localStorage.removeItem('filters_:tagId');
await loadFilters(api)
location.reload();
}
function validateDate(text) {
Expand Down

0 comments on commit 18dcdf2

Please sign in to comment.