I’m developing a dashboard which contains a data table. With some checklists in drop downs I am filtering the content of this table. To make the usage easier I implemented for each list a “Select All” and a “Unselect All” button. The callback for this looks as follows:
@app.callback(
dash.dependencies.Output({'type': 'checkbox_list', 'index': MATCH}, 'value'),
[dash.dependencies.Input({'type': 'select-all-button', 'index': MATCH}, 'n_clicks'),
dash.dependencies.Input({'type': 'unselect-all-button', 'index': MATCH}, 'n_clicks')],
[State({'type': 'checkbox_list', 'index': MATCH}, 'options'),
State({'type': 'checkbox_list', 'index': MATCH}, 'value')]
)
def select_all(select_all_button, unselect_all_button, options, value):
changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0]
if 'unselect-all-button' in changed_id:
return []
elif 'select-all-button' in changed_id:
return [i['value'] for i in options]
else:
# return the already existent value
return value
I got multiple filters which work fine with the pattern matching callbacks. But now I also want to have a “Delete All Filters” button. How would I implement this?
One idea would be to somehow trigger all the "select-all-button"s, the other would be to implement this delete-all-filters button in the above function. But I can not figure out how.
Thanks for your help!