Keep filters and table data when navigating back in Perspective

Hello all,

In my Perspective project, I have a page with filters and a table.

Users set filters, run a query, and see results in the table. When they click a row, I navigate to a detail page. After going back, the onStartup script runs again, resetting filters and clearing the table.

I want the page to look exactly as it did before navigation. What’s the best way to preserve state between pages in Perspective? Should I move the state to a parent property, or is there another recommended approach?

Yes you want to move the state “higher”, in this case to a Session Property, so it would remain the same after the user navigates away and back.

It sounds like the startup script would need to be adjusted to look at the Session Properties, and if they exist: not reset the values. With Session Properties you could likely avoid some of the startup script by instead having the Session props default to an empty string, and binding the filter components to the Session props. Then once the user starts to filter with them, the session will preserve their input before and after navigation in the Session props.

Thanks.

What’s the best practice to preserve state between pages in Perspective?

  • Should I store state in Session Properties (e.g., session.custom.filters) so it survives navigation?

  • Or pass values via Page Params from parent → child?

1 Like

Good question, it somewhat depends on if the page will be used multiple times, such as on multiple browser tabs at once.

If you need each page (which I am assuming is mainly the view with the table and filtering) to have distinct filters, then you may find more value in Page Params so they are different per URL.

If you are instead treating it more like a mobile app, or don’t expect the users to user the table on multiple tabs at once, the Session props work.