Skip to Content

sap.m.SearchField - filter suggestions

Jan 16 at 03:23 PM


avatar image


I want to filter the suggestions on a sap.m.searchField based on a fuzzy search.

In a first step I just try to get the full list with a simple filtering.

I have been able to implement suggestions on the sap.m.searchField and when I enter some characters in the searchField the suggestions that contain the characters are bolded.

But what I want to do is to show only the ones that contain the characters I type and not the other ones. How can I implement it?

I have taken as sample for my development the following sapui5 sample:

And here you have my code.

Definition of the searchField:

<SearchField id="searchField" showRefreshButton="{= !${device>/support/touch} }" tooltip="{i18n>masterSearchTooltip}" width="100%"
  enableSuggestions="true" suggest="onSuggest" 
     path: '/bpg',
     sorter: { path: 'GroupName' }
     <SuggestionItem text="{GroupName}" description="{path: 'GroupCode'}" key="{GroupCode}"/>

Implementation of the onSuggest.

With the line


commented the suggestions are presented without filters.

If I uncomment the line the suggestions are not anymore shown.

onSuggest: function(event) {
  var searchField = this.byId("searchField");
  var sValue = event.getParameter("suggestValue");
  var filters = [];
  if (sValue) {
    filters = [
        new sap.ui.model.Filter([
          new sap.ui.model.Filter("GroupName", function(sText) {
            return (sText || "").toUpperCase().indexOf(sValue.toUpperCase()) > -1;
          new sap.ui.model.Filter("GroupeCode", function(sDes) {
  	    return (sDes || "").toUpperCase().indexOf(sValue.toUpperCase()) > -1;
      ], false)


Do you have an idea where can be the problem?

In a second step I'll try to adapt the sample to work with a Fuzzy Search query but for the moment a simple filtering should be enough.

PS: I have checked the following thread for the fuzzy search but I'll like to keep using the searchField as created by Fiori Master-Detail template instead of using Input.

Thanks in advance for your ideas


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers