Hi, I can’t figure out how to update my Dash DataTable using DateRangePicker as input while also retaining interactive capabilities. My main issue is that I want to update my table depending on some date selected by DateRangePicker. But in order to do so, I need to make the DataTable in a @callback rather than have it as a Div already made without any callbacks. The problem with making the data table in a callback is that when the table is updated, I can no longer click the table and have the interactive features, all that happens is the table is refreshed and then the “active_cell” value is always equal to None. Here is some code of what I have working now
dbc.Col(
[
html.Div(
dash_table.DataTable(
id='corr-table',
columns=[{"name": i, "id": i} for i in correlation_dataframe.columns],
data=correlation_dataframe.to_dict('records'),
active_cell=initial_active_cell,
),
)
@callback(
Output('corr-graph', 'figure'),
[Input('corr-table', 'active_cell'),
Input('corr-table', 'data'),
Input("stored-data", 'data'),
],
)
# active_cell = None if dash_table.DataTable is made in a callback.
def update_graph(active_cell, data, stored_data):
name, start_date, end_date = stored_data
if active_cell:
df = client_df if name == "xxx" else client_df.loc[name]
df = format_dates(df, start_date, end_date)
selected_table_row_num = active_cell['row']
row_name = data[selected_table_row_num][' ']
column_name = active_cell['column_id']
fig = px.scatter(data_frame=df, x=column_name, y=row_name, trendline="ols", trendline_color_override="red")
return fig