hello guys , i hope y’all doing great . i’m building a dash app project . and i have this bug in the code , it’s metric web app that renders different pages, on the history page there is a datatable which is meant to be updates based on a particulat callback .i wrote a clean code but the callback is not trigerred when i change the date:
elif pathname == "/page-2":
layout = dbc.Container([
html.H1("Trade Tracker App"),
# Filtres pour choisir la date et les mois
dcc.DatePickerSingle(
id='date-picker',
date=df['dates'].min(), # Valeur par défaut : date minimale dans les données
display_format='YYYY-MM-DD',
style={'margin-bottom': '20px'}
),
dcc.Dropdown(
id='month-dropdown',
options=[
{'label': month, 'value': month} for month in df['dates'].dt.strftime('%B').unique()
],
multi=True,
placeholder="Sélectionner un ou plusieurs mois...",
style={'margin-bottom': '20px'}
),
dash_table.DataTable(
id='filtered-data-table',
columns=[
{'name': col, 'id': col} for col in df.columns
],
data=df.to_dict('records'),
style_table={'overflowX': 'auto'},
page_size=10, # Définir le nombre de lignes par page
style_cell={'textAlign': 'left'},
)
])
# Callback pour mettre à jour le tableau en fonction des filtres
@app.callback(
Output('filtered-data-table', 'data'),
[Input('date-picker', 'date'),
Input('month-dropdown', 'value')]
)
def update_filtered_data_table(selected_date, selected_months):
print("callback trigerred")
filtered_df = df.copy()
if selected_date:
filtered_df = filtered_df[filtered_df['dates'] == selected_date]
updated_data = filtered_df.to_dict('records')
return updated_data
return layout
the data is displaying but the callback is ineffective
please help ME. thank you very much