Hi,
I have a data table with the option of selecting a row that gives the required information to retrieve data with a sql query. This data updates a graph.
This is working perfectly until I implemented the option to sort by columns in the data table, instead of taking the data from the new location it takes the data that was initially there before sorting. What could i do to reset the index so it updates correctly?
Below is simplified layout and callback.
dash_table.DataTable(id='DataStat',
data=df_stat.to_dict("records"),
columns=[{"name":col,"id":col} for col in list(df_stat.columns)],
#style_as_list_view=True,
style_cell = {'textAlign':'center'},
style_header = {'fontSize':14, 'verticalAlign':'center', 'paddingTop':10,
'paddingBottom':0},
editable=False,
filter_action="native",
sort_action="native",
sort_mode="multi",
row_selectable="single",
row_deletable=True,
selected_rows=[],
page_action="native",
page_current= 0,
page_size= 30,
style_as_list_view=True)
@app.callback(
[Output('QuickGraph','figure'),
Output('Histogram','figure')],
[Input('DataStat','derived_viewport_selected_rows')],
[State('DataStat','data')])
def Quick_Process_view(selected,DATA):
if selected:
rowdata=DATA[selected[0]]
fig=somefunc(rowdata)
return fig