Hi,
I have two Dropdowns:
dcc.Dropdown(
id='departments',
options=[{'label': f"{dep}", 'value': f"{dep}"} for dep in sorted(df.department.unique())],
value=['dep01'],
multi=True
),
dcc.Dropdown(
id='employees',
# options=[{'label': emp, 'value': emp} for emp in sorted(df.employee.unique())],
# value=['P01'],
multi=True
),
and a call back:
@app.callback(
Output('employees', 'options'),
Input('departments', 'value'),
Input('include_dep_employees', 'value'))
def set_cities_options(departments, include_dep_employees):
if include_dep_employees == ['Y']:
emps = sorted(df.query("department.isin(@departments)").employee.unique())
else:
emps = sorted(df.employee.unique())
return [{'label': emp, 'value': emp} for emp in emps]
If I select a department, I see only employees from selected department, but…
If I select two departments, and one employee from each department, and than remove one department, previously selected employee from removed department is still among values.
I would like to remove employee from employees dropdown if its department is removed.
How to do that?
Regards.