I am trying to use selected_row_indices in a callback, following a bunch of examples from the forum. But clicking on the cells does not trigger any callback and the initial callback when loading the page as well as callbacks triggered by Intervals will return None as input data
import dash_table as dtbl
dfext = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')
app.layout = html.Div([
dtbl.DataTable(
id='datatable',
columns=[{"name": i, "id": i} for i in dfext.columns],
data=dfext.to_dict('records'),
row_selectable='multi'
),
dcc.Interval(id='refresh', interval=10 * 1000, n_intervals=0),
html.P(id='dummy'),
])
@app.callback(
Output('dummy','children'),
[Input('refresh','n_intervals'),
Input('datatable', 'rows'),
Input('datatable', 'selected_row_indices')])
def f(n, rows,selected_row_indices):
print(selected_row_indices)
print(rows)
return []
The callbacks get triggered on the Intervall, but variables printed are
Sorry, that was just a mistake when writing the question. While formulating it I tried it again with exactly that example in one of the other questions in the forum and I did not update all part of the question. so, the names/ids are the same. I editedthe question
@ziczac
you need component properties that are actual properties of a datatable. selected_row_indices and rows do not exist. Maybe you are referring to selected_rows or derived_virtual_data.
There’s a difference between the strings that go inside a callback Input and the arguments that go inside the callback function. For a deeper explanation, read this documentation or see this tutorial.