✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Left priority in dropdown search

Say I have two labels in my dropdown:

ab
b

If I were to search “b” I would see “ab” above “b” in the dropdown options. Is there a way to make the search read from the left so that we see “b” above “ab” in the dropdown options?

chriddyp pointed me to the Dynamic Options example on https://dash.plotly.com/dash-core-components/dropdown and I solved it using:

return [o for o in options if re.match(search_value, o[“label”], re.IGNORECASE)]

for front matches only or:

opt = [o for o in options if re.match(search_value, o[“label”], re.IGNORECASE)]
opt.extend([o for o in options if o not in opt and search_value in o[“label”]])
return opt

2 Likes

thanks market, very much appreciated