Hello:
In my application I have to use a checklist inside a dbc.DropdownMenu. When I click the DropdownMenu, the checklist will list the items and I can select or de-select options. if I want to close the DropdownMenu, I would have to click outside of the DropdownMenu. What I want is to catch the DropdownMenu close event so that I can get the selected items from the checklist. If you know how to do that, please share with me. I really appreciate all your help. Below is the sample code. I commented the callback as obviously it will not work but it shows what I want.
from dash import Dash, dcc, html, Input, Output
import dash_bootstrap_components as dbc
app = Dash(name)
app.layout = html.Header([
html.Div(
children =[ dbc.DropdownMenu(
children = [
dcc.Checklist(
options = [‘NYC’, ‘MTL’, ‘SF’],
id=‘demo-checklist’,
labelStyle={“display”:“block”}),
],
label = "College",
id = 'demo-dropdownmenu'),
html.Div(id='demo-div'),
])])
“”"
@app.callback(
Output(‘demo-div’, ‘children’),
Input(‘demo-dropdownmenu’, ‘is_closed’)
State(‘demo-checklist’, ‘value’),
)
def update_output(is_closed, value):
if is_closed:
return f’selected items: {value}’
else:
return 'not closed"
“”"
if name == ‘main’:
app.run_server(debug=True, port=8060)