Dash Datatable - Starting page number from previous run is retained

Hello, I’m using a Dash DataTable with native pagination. When a result returns multiple pages and the user uses the arrows on the lower right to page down to any page number, that number seems to be retained across invocations. If the next submission returns a table with fewer pages than the previous one, no pages are displayed. It seems the placeholder in the ‘current-page’ input field is being retained across executions. I tried setting ‘page_current’ to both 0 and 1 in the DataTable object.

dash_table.DataTable(id=table_id,
                         sort_action="native",
                         sort_mode="single",
                         page_action="native",
                         page_size=50,
                         page_current = 0,
                         export_format='xlsx',
                         export_headers='display',
                         columns=[{'id': c, 'name': c} for c in df.columns],

Thanks in advance, I love Dash!
Hank Calzaretta

Hi @HankCalzaretta and welcome to the Dash community :slight_smile:

I’ve noticed this as well, and I think it’s the same issue as reported here: go back to page 1 when data is updated and you are on a page that no longer exists · Issue #698 · plotly/dash-table · GitHub

One work-around is to update page_current in a callback.

Thank you so much @AnnMarieW! Your suggestion worked perfectly and saved me tons of time!

-Hank

1 Like