Search code examples
sapui5

Adding suggestionItems Fails: "Cannot add direct child without default aggregation defined for control sap.m.SearchField"


I am adding a SearchField with suggestions in the XML view. When I execute, I get the error

Error: Cannot add direct child without default aggregation defined for control sap.m.SearchField.

Please tell me what mistake I am making.

<SearchField
  placeholder="final search"
  tooltip="Search for datastore source names"
  suggestionItems="{/records}"
  selectOnFocus="true"
>
  <suggestionItems>
    <SuggestionItem
      text="{dbname}"
      description="{dbname}"
    />
  </suggestionItems>
</SearchField>

Solution

  • Try to have a look to this example

    sap.m.Input

    suggestionItems="{/ProductCollection}" is the collection with all the available entries, text="{Name}" is one of the attributes of the collection item.

    Check this example without search help https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.InputSuggestionsDynamic/preview or https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.InputSuggestionsCustomFilter/preview