Hello, I’m a bit new to using dash and I’m having some trouble with updating a dropdown callback so that options are given based off of the searchValue being a length of >2 and then stored in the url.
The dropdown doesn’t update when the page is refreshed but the stored value still allows the callbacks further down the line to still create figures.
Is there a way for the selected/stored value to show up in the dropdown when the page is refreshed while still allowing search of a new item to happen in the dropdown?
dcc.Dropdown(id='gene_page_select_gene',
placeholder='Enter gene',
value=gene,
),
@callback(
inputs=[
Input('gene_page_select_gene','value'),
Input('gene_page_select_histogram_metric','value'),
Input('gene_page_select_histogram_colorby','value'),
Input('gene_page_select_signature_method','value'),
Input('gene_page_store_selected_target','children'),
Input('gene_page_select_signature_plot_metric','value')
],
output=Output('gene_page_url_output','search')
)
def gene_page_update_url(
gene,
histogram_metric,
histogram_colorby,
signature_method,
selected_target,
signature_plot_metric,
):
d={ 'gene':gene,
'histogram_metric':histogram_metric,
'histogram_colorby':histogram_colorby,
'signature_method':signature_method,
'selected_target':selected_target,
'signature_plot_metric':signature_plot_metric,
}
d={k:v for k,v in d.items() if v}
print('updating url',d,flush=True)
return '?'+urlencode(d)
@callback(inputs=[Input('gene_page_select_gene','search_value')],
output=Output('gene_page_select_gene','options'))
def fill_gene_dropdown(search_value):
if (not search_value) or len(search_value)<2:
raise PreventUpdate
else:
s=mmd.get_all_genes()
return [{'label':v,'value':v} for i,v in s[s.str.startswith(search_value)].iteritems()]