Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Pagination doesn't work when more than one table is on the page #834

Closed
chriddyp opened this issue Sep 29, 2020 · 2 comments · Fixed by #907
Closed

Pagination doesn't work when more than one table is on the page #834

chriddyp opened this issue Sep 29, 2020 · 2 comments · Fixed by #907
Milestone

Comments

@chriddyp
Copy link
Member

import dash
import dash_table
import dash_html_components as html
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')

app = dash.Dash(__name__)

table1 = dash_table.DataTable(
    id='table1',
    columns=[{"name": i, "id": i} for i in df.columns],
    data=df.to_dict('records'),
    page_action="native",
    page_size=5,
)

table2 = dash_table.DataTable(
    id='table2',
    columns=[{"name": i, "id": i} for i in df.columns],
    data=df.to_dict('records'),
    page_action="native",
    page_size=7,
)

app.layout = html.Div([
    table1,
    table2
])

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

As reported in https://community.plotly.com/t/potential-bug-dash-datatable-paging-for-multiple-datatables-on-the-same-page/45431

@chriddyp chriddyp added the bug label Sep 29, 2020
@Marc-Andre-Rivet Marc-Andre-Rivet added this to the OSS milestone Sep 30, 2020
@abondrn
Copy link

abondrn commented Oct 26, 2020

I am encountering this as well. As in the original post, the first table has page numbers but is unresponsive when you click or try to type in a page number, however this works fine on the second table.

Interestingly, other native interactivity such as sorting and filtering work just fine, so my guess is the culprit lies in how the pager is linked to the table, rather than the other way around. I'd love to take a crack at this, but I'm not at all familiar with the codebase, would greatly appreciate pointers.

@mrspieb
Copy link

mrspieb commented Jan 26, 2021

I just had the same issue. It seems to be an error with the spacing underneath the table. The following workaround works for me:

import dash
import dash_table
import dash_html_components as html
import pandas as pd

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

app = dash.Dash(__name__)

table1 = dash_table.DataTable(
    id="table1",
    columns=[{"name": i, "id": i} for i in df.columns],
    data=df.to_dict("records"),
    page_action="native",
    page_size=5,
)

table2 = dash_table.DataTable(
    id="table2",
    columns=[{"name": i, "id": i} for i in df.columns],
    data=df.to_dict("records"),
    page_action="native",
    page_size=7,
)

app.layout = html.Div(
    [
        html.Div(table1, style={"padding-bottom": "50px"}),
        table2
    ]
)

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

AnnMarieW pushed a commit to AnnMarieW/dash-table that referenced this issue Jun 1, 2021
AnnMarieW pushed a commit to AnnMarieW/dash-table that referenced this issue Jun 1, 2021
alexcjohnson added a commit that referenced this issue Jun 25, 2021
issue #834 fix when pagination doesn't work when more than one table …
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants