2016-11-18 119 views
-1

我已經綁定了json數據以在sapui5中查看。但我希望通過選定的ID顯示來自json的敬酒。SearchField sapui5顯示來自json的數據

JSON數據:

var data_suggest = [{"key":"1","value":"value dari 1", "description": "Satu"}, 
        {"key":"2","value":"value dari 2", "description": "Dua"}, 
        {"key":"3","value":"value dari 3", "description": "Tiga"}] 

視圖:

   <m:SearchField id="idSearchBy" 
           enableSuggestions="true" 
           suggest="onSuggest" 
           liveChange="onLiveChange" 
           search="onSearchBy" 
           placeholder="Search..." 
           suggestionItems="{ 
            path: 'suggest_model>/', 
            sorter: {path : 'suggest_model>value'} 
           }">     
        <m:suggestionItems> 
         <m:SuggestionItem text="{suggest_model>value}" key="{suggest_model>key}"/> 
        </m:suggestionItems>  
       </m:SearchField> 

我想當運行onSearchBy功能,示出了從JSON通過選擇的ID形式SearchField值鍵,值和描述。

如何解決這個問題?

回答

0

試試這個。它的工作原理:

<SearchField 
    id="idSearchBy" 
    placeholder="Search for..." 
    enableSuggestions="true" 
    search="onSearch" 
    suggest="onSuggest" 
    suggestionItems="{ 
     path: '/suggest_model', 
     sorter: { path: 'key' } 
    }" 
> 
    <suggestionItems> 
     <SuggestionItem text="{value}" key="{key}"/> 
    </suggestionItems> 
</SearchField> 

你可以檢查和下載example

相關問題