Hi everybody. Guys, maybe someone can help. There are 3 dropdowns, the second depends on the first, the third is independent of the first values, and the fourth depends on the values of the first three. if the first three are known, you can download the report. until the previous dropdown is selected, the rest are disabled. during value updates, the placeholder changes from ‘loading’ to empty. I have one nuance that does not work as it should. after loading the report with the selected value of the fourth dropdown, if you change the values of the first dropdown, the placeholder of the fourth with ‘loading’ is triggered, although this should not happen. it should change simply to ‘All’ if a value was selected there. otherwise, do not change. here is my code on callbacks
@dash.callback(
output=(Output('dropdown2', 'disabled'), Output('dropdown2', 'options'), ),
inputs=Input(dropdown1', 'value'),
running=[ (Output('dropdown2', 'placeholder'), 'Loading...', 'Select container',),
(Output('dropdown2', 'disabled'), True, False), ],
prevent_initial_call=True,
background=True,
manager=background_callback_manager
)
def choose_cnt(dd1):
if dd1:
return False, {func for get_dd2(dd1)}
else:
return True, dash.no_update
@dash.callback(
output=(Output('dropdown2', 'value'), Output('dropdown2', 'disabled', allow_duplicate=True),
Output('dropdown4', 'value', allow_duplicate=True), ),
inputs=( Input('dropdown1', 'value'), ),
state=(State('dropdown2', 'value'), ),
prevent_initial_call=True,
background=True,
manager=background_callback_manager
)
def update_cnt(dd1, dd2):
if dd1 and dd2 is None:
raise PreventUpdate
elif dd1 and dd2:
return None, True, None
@dash.callback(
output=(Output('dropdown4', 'disabled', allow_duplicate=True),
Output('dropdown4', 'options', allow_duplicate=True), ),
inputs=(Input('dropdown2', 'value')),
state=(State('dropdown1', 'value'), State('dropdown3', 'value'), ),
running=[(Output('dropdown4', 'value'), 'Loading...', None),
(Output('dropdown4', 'placeholder'), 'Loading...', 'All'),
(Output('dropdown4', 'disabled'), True, False), ],
prevent_initial_call=True,
background=True,
manager=background_callback_manager,
)
def update_assets(dd2, dd1, dd3):
try:
if dd1 is None or dd2 is None:
return True, dash.no_update
elif dd3 is None:
dd3= '{1 value from dd3 list}'
df = {func for get dd4(dd1, dd2, dd3)}
options = df.columns
return False, options
except:
raise PreventUpdate
# @app.long_callback(
@dash.callback(
output=(Output('grid', 'children'), ),
inputs=(Input('submit-btn', 'n_clicks'), ),
state=(State('dropdown1', 'value'), State('dropdown2', 'value'),
State('dropdown3', 'value'), State('dropdown4', 'value'), ),
running=[ (Output("submit-btn", "disabled"), True, False), ],
prevent_initial_call=True,
background=True,
manager=background_callback_manager,
)
def pk_grid(n_click, dd1, dd2, dd3, dd4):
some func for loading report