cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain SuggestedItem in a SAPUI5 SearchField?

UlisesCasal
Explorer
0 Kudos
124

Hello everyone!! I need to get the SuggestedItem selected by a user within a SearchField, but specifically, I need to get the key associated with the SuggestedItem selected by the user. Here is the code for my view:

<SearchField
											enableSuggestions="true"
											enabled="true"
											placeholder=""
											showRefreshButton="false"
											showSearchButton="true"
											suggestionItems="{path: '/ExampleSet'}" 
											suggest=".onSuggest"
											value=""
											visible="true"
											width="auto"
											tooltip="Buscar empleado"
											id="searchField"
											change="onSeleccionado"
											suggestionItemSelected="suggestionItemSelected"
										>
											<suggestionItems>
												<SuggestionItem text="{Sname}" key="{Pernr}" description="      {Pernr}"/>
											</suggestionItems>

 I tried with suggestionItemSelected but the event is not triggered. How can I get the key of the SuggestionItem?

View Entire Topic
M-K
Active Participant
0 Kudos

Hi, you can use the search event, it should give you the selected SuggestionItem.
Then get the key with the getKey function of the item.