Search code examples
javascriptsapui5

How to pass 2 data model sources to the SearchField


I'd like to pass data from 2 sources to the Searchfield control through parts as in an example here. https://openui5.hana.ondemand.com/#/topic/dfe04650afc046e0802abb1a1a90d2d9

My code:

<SearchField
    id="mySFID"
    enableSuggestions="true"
    search="onSelectDiseaseTerm"
    suggest="onSuggestDiseaseTerm1"
    suggestionItems="{
    parts : [
        {path: 'db2>/SOURCE1/'},
        {path: 'db2>/SOURCE2/'}],
    type: 'sap.m.SearchField'}" >
<suggestionItems>
    <SuggestionItem
            text="{db2>DISEASE_TERM}"
            key="{db2>DISEASE_TERM}" />
</suggestionItems>
</SearchField>

This is failing with the following trace


    Cannot route to target: TypeError: w[b].push is not a function -  
    f   @   sap-ui-core.js:82
    error   @   sap-ui-core.js:82
    (anonymous) @   MyRouter.js?eval:77
    Promise.catch (async)       
    _checkSessionBeforeRoute    @   MyRouter.js?eval:76
    parse   @   MyRouter.js?eval:116
    fnHashChanged   @   Router.js?eval:6
    o.fireEvent @   EventProvider.js?eval:6
    n.fireHashChanged   @   HashChanger.js?eval:6
    execute @   signals.js?eval:93
    dispatch    @   signals.js?eval:384
    Signal.dispatch @   signals.js?eval:187
    (anonymous) @   hasher.js?eval:126
    setHash @   hasher.js?eval:375
    n.setHash   @   HashChanger.js?eval:6
    navTo   @   Router.js?eval:6
    onOpenOrderEditView @   CaseList.controller.js?eval:171
    o.fireEvent @   EventProvider.js?eval:6
    r.fireEvent @   Element.js?eval:6
    (anonymous) @   ManagedObjectMetadata.js?eval:6
    a.<computed>    @   Icon.js?eval:6
    r._handleEvent  @   Element.js?eval:6
    l._handleEvent  @   UIArea.js?eval:6
    dispatch    @   sap-ui-core.js:26
    q.handle    @   sap-ui-core.js:25


Solution

  • SearchField's suggestionItems is an aggregation that takes an array of sap.m.SuggestionItem as input. You cannot pass what you're trying to do.