Skip to content

[BUG] DataTable: Page number is not persisted through browser page refresh #1860

@urig

Description

@urig

Describe your context

I'm running Dash app from a python program.

  • replace the result of pip list | grep dash below
dash                              2.0.0
dash-bootstrap-components         1.0.0
dash-core-components              2.0.0
dash-html-components              2.0.0
dash-renderer                     1.9.1
dash-table                        5.0.0
dash-ui                           0.4.0
  • if frontend related, tell us your Browser, Version and OS

    • OS: Windows 10
    • Browser Firefox, Chrome
    • Version 94, 96 (respectively)

Describe the bug

My app has a DataTable and I've enabled persistence recently. Now I find that after a page refresh in the browser, the page number in the table is not persisted.

Steps to reproduce:

  1. Store the program below in a python file.
  2. Run the file with dependencies as show above.
  3. In the browser a table will be shown with paging controls below it.
  4. Change to a page other than page number 1.
  5. Refresh the page.

Code:

import dash
import dash_table
import pandas as pd
from dash import html

df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/solar.csv")
app = dash.Dash(__name__)

app.layout = html.Div(
    [
        dash_table.DataTable(
            id="table",
            columns=[{"name": i, "id": i} for i in df.columns],
            data=df.to_dict("records"),
            persistence=True,
            page_action="native",
            page_size=6,
        ),
        html.Div(id="output"),
    ]
)

if __name__ == "__main__":
    app.run_server(debug=True)

Expected behavior

After the page is refreshed the table remain in the same page number as before refreshing.

Actual behavior

After the page is refreshed the table returns to page number 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions