Toml
1
My goal is to chain two multi selectable dropdown callbacks, but I didn’t succeed. Here is, what I tried:
@app.callback(
Output('merkmal_chosen', 'options'),
[Input("timeline_chosen", "value"),
Input('kategorie_chosen', 'value')
]
)
def set_merkmale_options(timeline, kategorie_chosen):
if timeline == '1':
df_f = d_bis17[(d_bis17['KATEGORIE'].isin([kategorie_chosen]))]
return [{'label': l, 'value': l} for l in sorted(df_f['BEZEICHNUNG'].unique())]
elif timeline == '2':
df_f = d_ab18[(d_ab18['KATEGORIE'].isin([kategorie_chosen]))]
return [{'label': l, 'value': l} for l in sorted(df_f['BEZEICHNUNG'].unique())]
If I select a list of elements in first dropdown, nothing ist shown in second chained dropdown.
Hello @Toml,
Try running with debug=True in the app.
My guess is that the filtering is operating as a list of lists when you are trying to filter. So, it’s not working the right way.
I’d say, take the ‘kategorie_chosen’ out of the brackets.
Toml
3
Hi @jinnyzor,
thanks for the advice. Debug Mode doesn’t show any error messages.
Taking out ‘kategorie_chosen’ from the brackets throws an error, that
only list-like objects are allowed to be passed to isin()
The problem is that both dropdowns should be multi selectable. I have no clue…
Can you give an MRE?
Right now, I can’t run it with the code provided. If you provide an MRE, I can make suggestions from there.