Combobox : Custom sorting dependent on input value


we want to implement custom sorting in our ComboBox.

Dependent on the text value that is entered, the exactly fitting item has to appear at the very top of the suggestions.

If there is no exact fitting item, then the default sort order can kick in.

Does anybody know how to do this ?

We tried many different aproaches, but no one has worked out so far :slight_smile:

Only solution I can think of that might work is using a custom lazy DataProvider with a configurable filter (a ConfigurableFilterDataProvider, see more at the docs here: I haven’t tried it, though. Worth a try?


Hi Olli,

i found a solution from same page as you posted :slight_smile:

When emptySpace or colon is written in the combobox textField,
i only show the item with exact Key (if existing) else i just show default filtering.

Here my code translated to generic english

new ListDataProvider<>(suggestionProviderDao.loadComboboxItems())
.filteringBy((myItem, writtenText) → isExactItemWanted(writtenText)
? showOnlyExactItem(myItem, writtenText)
: myItem.contains(writtenText)

it’s not what i wanted, but it is exactly what is in my ticket :slight_smile:

I just wanted to surpass the ticket and make those special charakters obsolet