Is there a way to have a button on one page, trigger information for the next page without using dcc.Store?
As an example I would like the ‘prev-graph-button’ that is on the home page to redirect to the prev-graph page AND populate the ‘prev-report-drop’ dropdown. However when I tried to do the callback on home.py it told me that ‘prev-report-drop’ was not an option. I also tried moving the callback to my app.py but it didn’t work there either.
home.py
layout = html.Div([
dbc.Row([
html.Center([
dbc.Button(
'See Graphs for Previous Meetings',
id='prev-graph-button',
n_clicks=0,
color='secondary',
outline=True
)
])
],
style={'margin-top': '30px'}),
dcc.Location(id='graph-redirect', pathname='/'),
dcc.Location(id='prev-graph-redirect', pathname='/')
)]
@callback(
Output('prev-graph-redirect', 'pathname'),
Output('prev-report-drop', 'options'),
Input('prev-graph-button', 'n_clicks')
)
def prev_graph_page(n1):
if n1:
report_df = pod.get_prev_reports()
return '/prev-graph', report_df.ReportName[-2:]
prev-graph.py
layout = html.Div([
html.Center([
html.H4('Select a Previous Report'),
dcc.Dropdown(
id='prev-report-drop',
options=[],
placeholder='Report',
style={'width': '160px', 'text-align': 'left', 'margin-top': '20px'}
)
],
style={'margin-top': '20px'})
)]
My main reason for needing to do this is I originally would call the function get_prev_reports() on page load and had report_df.ReportName[-2:] directly in options. But when deploying on a Docker container, the options don’t update with the app. So I need a trigger to call the function instead of having it on page load one time. So if anyone has other ideas than my initial question, I’m open to suggestions.