The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Custom filter widget - how to retain the filter after being redirected to another page?

JordyZ
Mega Sage

Hi,

 

We have a custom filter widget on the service portal, the filter widget shows the desired records depending on the filter conditions. 

Upon clicking the desired record, the page redirects (so no pop-up) to the record. When pressing/going back, the filter's reset again. 

 

Is it possible to have the filter saved even when going back? If so, how?

 

Filter:

JordyZ_2-1739266784238.png

 

Redirect to new screen

JordyZ_1-1739266694805.png

 

Go back, filter's reset

JordyZ_3-1739266843377.png

 

Any help would be greatly appreciated!

 

 

1 REPLY 1

Kieran Anson
Kilo Patron

For values like this, you can cache the value in the browser. You have two options, session storage and local storage.

Session Storage exists for the duration of the user session, so if they expire or logout the data is lost. Local storage persists.

 

//Retrieve a value based on 'itemKey'
$window.sessionStorage.getItem('itemKey');

//Save a value based on a 'itemKey'
var myFilterValue = 'active=true';
$window.sessionSotrage.setItem('itemKey' , myFilterValue);

You could also look to bring in a directive such as ngStorage