Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Sorting Dropdown Search Results

Its easy to sort options in dropdowns

rc.Column(
    width=3,
    children=[
        html.Strong("Benchmark (Excess Return)"),
        dcc.Dropdown(
            id='benchmark-dropdown',
            options=sorted([{'label': benchmarks['long_name'][i], 'value': benchmarks['id'][i]}
                            for i in range(0, len(benchmarks))], key=lambda k: k['label']),
            value=292,
            disabled=True,
            clearable=False,
            className="dropdown default minimal"
        )
    ]
),

Pre Search
image

But how do we construct our dropdown properly to sort the search results?

Post Search
image

1 Like

I am also looking for same thing… There should be an option in dash which lets us decide if you want to perform pattern matching with the whole string in dropdown elements or display those results which starts with the searched character in search string.

If you’ve found a way around then please share.