Hi Eduardo,
please see mentioned parts from my code:
PAGE_SIZE = 10
def create_DashTable(df):
return dash_table.DataTable(
id='datatable-paging',
#data=df.to_dict('records'),
columns=[{'name': i, 'id': i} for i in df.columns],
page_current=0,
page_size=PAGE_SIZE,
page_action='custom'
)
content = html.Div(id="page-content", children=[], style=CONTENT_STYLE)
app.layout = html.Div([
dcc.Location(id="url"),
sidebar,
content
])
@app.callback(
Output('datatable-paging', 'data'),
Input('datatable-paging', "page_current"),
Input('datatable-paging', "page_size"))
def update_table(page_current,page_size):
return df_myTradesList.iloc[
page_current*page_size:(page_current+ 1)*page_size
].to_dict('records')
@app.callback(
Output("page-content", "children"),
[Input("url", "pathname")]
)
def render_page_content(pathname):
if pathname == "/":
return [
html.H1('TK TEST',
style={'textAlign':'center'}),
dcc.Graph(id='bargraph',
figure=px.bar(df, barmode='group', x='Years',
y=['Girls Kindergarten', 'Boys Kindergarten']))
]
elif pathname == "/page-1":
return [
html.H1('PAGE 1 Grad School in Iran',
style={'textAlign':'center'}),
dcc.Graph(id='bargraph',
figure=px.bar(df, barmode='group', x='Years',
y=['Girls Grade School', 'Boys Grade School']))
]
elif pathname == "/page-2":
return [
html.H1('myTradesList data',
style={'textAlign':'center'}),
html.P(
"myTradesList:" , className="lead"
),
create_DashTable(df_myTradesList)
]
# If the user tries to reach a different page, return a 404 message
return dbc.Jumbotron(
[
html.H1("404: Not found", className="text-danger"),
html.Hr(),
html.P(f"The pathname {pathname} was not recognised..."),
]
)
if __name__=='__main__':
app.run_server(debug=True, port=3001)
so, not sure now