cancel
Showing results for 
Search instead for 
Did you mean: 

sap.m.input suggestItem suggestionItemSelected event is problem

0 Kudos
2,306
Hi Experts,


To build the Fiori application of SAPUI 5,
I am trying to realize a suggestion function using suggestItem of sap.m.input.


Therefore, when implementing and executing the suggestionItemSelected event,
I succeed in choosing the first suggestion list,
I have encountered an obstacle in which selectedItem is set to null for the second time.


<xml>
	<Input id="itxtVkorg" 
		maxSuggestionWidth="800px" 
		type="Text"
		showSuggestion="true"
		suggestionItems="{ path: '/ZTVKO01Set', sorter: { path: 'Vkorg' } }" 
		suggestionItemSelected="onSelectItemVkorg"
		ariaLabelledBy="lblVkorg"
		>
		<suggestionItems>
			<core:ListItem key="{Vkorg}" text="{Vkorg}" additionalText="{Vtext}"/>
		</suggestionItems>
	</Input>
	<Text id="txtVkorg" text=""/>




<js>
	onSelectItemVkorg: function(oEvent) {
		
		// var ctl = sap.ui.getCore().byId("itxtVkorg");
		var item  = oEvent.getParameter("selectedItem");
		// var key = item.getKey();
		var text = item.getAdditionalText();
		
		// sap.ui.getCore().byId("itxtVkorg").setValue(key);
		sap.ui.getCore().byId("txtVkorg").setText(text);
	},


Do you know anything, workaround?


Regards
View Entire Topic
former_member340030
Contributor
0 Kudos

Hi Akitaka Shimizu,

Are you saying when you select your second Item from the suggestion list , the selected value is coming null or you want to null the selected Item .. please can you elaborate your problem

thanks

Viplove

0 Kudos
Thanks Viplov.

My problem is the second choice of a suggestion list,
(the selected value is coming null)


var item = oEvent.getParameter ("selectedItem");
Item is null.

It is an assumption that the "Class sap.ui.core.ListItem" of the second selected suggestionList will be returned correctly.


Regards.

former_member340030
Contributor
0 Kudos

Actually i am also using suggestion event for input in my Project its working fine .. might be you are missing something some where

thanks

Viplove

0 Kudos

Thanks Viplov.

In fact, the same phenomenon occurs even in the following samples, so please take a look, if you like.

Put "h" in the text, 1 time 2 times An error will occur.

http://jsbin.com/gonafimapu/edit?html,js,console,output

Regards.

former_member340030
Contributor
0 Kudos

Error comes like this after selecting first time from the suggested item , if we type anything in the input and remove focus from the input control it calls suggestionItemSelected event , which it should not call until and unless and item is selected. But for you why that's a problem, you can ignore that. What you can do if you still don't want to get that issue.You can just check if the value is not null than only get the additional text like this :

var item  = oEvent.getParameter("selectedItem");
If (item !== null){
		var text = item.getAdditionalText();
                sap.ui.getCore().byId("txtVkorg").setText(text);
}

Thanks

Viplove

Hi Viplove

sorry for the late reply.

To the contents taught, plus Without using suggestionItems, By using suggestionRows,

I confirmed that a null value will not be returned.

Thank you, I was rescued by my reply.