@sangerwoo wrote:
How can I populate the dropdown list on “onclick” event? I can get the list updated when someone selects the value but I can’t get it to update when the user clicks on the down arrow. My option list the files from a folder. I want to re-populate the list every time list is shown to catch new files added to a folder. callback happens when I select something on the dropdown but I can’t get the callback to happen when someone just clicks the dropdown arrow.
pathway = ‘C:/temp’
app.layout = html.Div([dcc.Dropdown(id=“filename”)])@app.callback(Output(‘filename’, ‘options’), [Input(‘filename’, ‘value’)])
def updateOptionList(n):
files=[f for f in listdir(pathway) if f.endswith(‘csv’)]
options=[ {‘label’: i, ‘value’: i} for i in files]
return options
Posts: 4
Participants: 3