Im building a plotly Dash dcc.dropdown list dynamically using :
def BuildOptions(DataFrameSeries, AddAll):
OptionList = [{'label': i, 'value': i} for i in DataFrameSeries.unique()]
if AddAll == 1:
OptionList.insert(0,{'label': 'All', 'value': 'All'})
return OptionList
it uses unique values in a df series, and inserts 'All' into the options list. I now want to Set the (default) value to 'All' if it exists or the [0] item in the list of K/V pairs.
html.Div([
dcc.Dropdown(
id='Prov_DD',
options=BuildOptions(data.TASKPROVINCE,1),
# value=data.TASKPROVINCE[0],
# value=dcc.Dropdown.value[0],
value='All' # this works for those list that have 'All'
# but I want [0] item
multi=True
)],className='two columns'
),
Any way of setting the dcc drop down to a certain item in the options list of key value pairs by index?