gwtgxt

GXT combobox to search from the keyword form anywhere in a word


I am using a GXT ComboxBox to search results from the store. But by default it search the word which STARTS from the keyword entered, What i want is to find the words from the store which have the entered keyword any where in that word.

So if i type "M" it only gives me "Maths", but I also want to see "sam" or "lamp"

Any idea how this can be achieved here.

thanks


Solution

  • Starting with GXT v4.0.3 you can use the QueryMatcher interface:

    myComboBox.setQueryMatcher((item, query) -> {
      String value = getPropertyEditor().render(item);
      if (value != null) {
        return value.toLowerCase()
                    .contains(query.toLowerCase());
      }
      return false;
    });
    

    Hope that helps.