1

I need to save the state of the PrimeNG table(p-table) filters in the query parameters of the url.

I know that PrimeNG has built-in features for saving state to local storage, but this method does not suit me because I need to save the state only if the user clicks on the table element, the navigation takes it to another page, and then when the user returns back the filters need to be applied.

Actually the problem is that I can put the state of the table filters in the query parameters of the url, but then the link is very long, about 500 characters(I don’t know if this is bad, maybe I should leave it as it is).

There was also an idea to push the state into the session storage, and store the key to the session storage in the query parameters, but then the user would not be able to follow the link and that the filters would be applied. Who has any ideas?

my code for getting the state of filters and adding them to url query parameters

const filters: FilterMetadata[] | FilterMetadata = this.dataTable.filters;
this.router.navigate(['test', id], {queryParams: {filters: JSON.stringify(filters)}});

0 Answers0