Datatable in Dash Multi-Pages App resets when I go to other page

I am creating a two-page Dash App using the Multi-Pages feature. In one tab, I have a Datatable which lists all the files in a specific directory (file name, file type, etc). I have an upload component below the Datatable which allows users to upload files to that directory. I made it to work using a callback to update the list of files in the Datatable. However, when I go to a different page and then return back to this tab, those files that I just uploaded didn’t show up in my Datatable (i.e. It resets to whatever I had when I run the code in the first place). Any help is appreciated! Thanks in advance!

Hello @williamwirono !

It is quie frequent question on this forum. Check out Store | Dash for Python Documentation | Plotly and Persisting User Preferences & Control Values | Dash for Python Documentation | Plotly.

Also check this forum post Show last retained value in the navigation bar. This was a similiar issue a while ago :slight_smile:

If dcc.Store does not fit your needs or you have some questions implementing it just reply back :slight_smile:

1 Like

I tried the persistence parameter within Dash Datatable but for some reason it didn’t work. Is there a specific entry I should apply for each persistence, persistence_type, and persistence_props parameters?

Honestly I never used persistence for DataTable. According to documentation Reference | Dash for Python Documentation | Plotly it looks like data is not persisted by default:

persisted_props (list of values equal to: ‘’, ‘data’, ‘filter_query’, ‘hidden_columns’, ‘page_current’, ‘selected_columns’, ‘selected_rows’ or ‘sort_by’ ; default [ '', 'filter_query', 'hidden_columns', 'page_current', 'selected_columns', 'selected_rows', 'sort_by'] ): Properties whose user interactions will persist after refreshing the component or the page.

Try to set persisted_props parameter to list:
[ ‘’, ‘data’, ‘filter_query’, ‘hidden_columns’, ‘page_current’, ‘selected_columns’, ‘selected_rows’, ‘sort_by’]

Got it to work by making use of the pages link in dcc.Location. I created a callback with dcc.Location as an input which updates the data in the Datatable as an output