Skip to Content
0

sap.m.input suggestItem suggestionItemSelected event is problem

Apr 27, 2017 at 06:10 AM

265

avatar image
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
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
VIPLOVE KHUSHALANI Apr 27, 2017 at 08:04 AM
0

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

Show 5 Share
10 |10000 characters needed characters left characters exceeded
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.

0

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

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.

0

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

0

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.

1