cancel
Showing results for 
Search instead for 
Did you mean: 

bind suggestion items dynamically for multi input control

0 Kudos

Hi,

could you please help with any working sample to bind the suggestion items dynamically with odata , without declaring the sugesstionItems{/} path in the view.

If I add the path in the view, it is causing performance issue due to large data amount. so i need to load the suggestion items, after the user is entering something in the control

In my case I'm binding it with an entity set as below which is causing more time to load the view as the $batch request i sloading all the items in the very first call from the app

<Input valueHelpOnly="false" id="id" showValueHelp="true" suggest="handleSuggest" showSuggestion="true" suggestionItems="{/EntitySet}" valueHelpRequest="openDialog" liveChange="onLiveChange" suggestionItemSelected="suggestionItemSelected"  change="onChange" valueStateText="Enter correct value">
<core:ListItem text="{text}" key="{key}"></core:ListItem>
</Input>


Controller:

handleSuggest: function(event) {
			var filter = [];
			var id= this.getView().byId("id").getTokens();
			if (id.length > 0) {
				id.forEach(function(item, id) {
					filter.push(new sap.ui.model.Filter("id", sap.ui.model.FilterOperator.EQ, item.getKey()));
				});
				if (filter.length == 0) {
					alert("error");
				}
				event.getSource().getBinding("suggestionItems").filter(filter);
				event.getSource().getBinding("suggestionItems").refresh(true);
			}


		},

Accepted Solutions (1)

Accepted Solutions (1)

imsuryapandiyan
Participant
0 Kudos

Mounika,

Try to bind suggestionItems in live change or suggest event handler.

handleSuggest: function(oEvent) {
	var oInput = oEvent.getSource();
	if (!oInput.getSuggestionItems().length) {
		oInput.bindAggregation("suggestionItems", {
			path: "/EntitySet",
			template: new sap.ui.core.Item({
				text: "{text}"
			})
		});
	}
}

Don't forget to remove binding and core:item in xml view.

Hope this helps.

Answers (3)

Answers (3)

former_member322772
Active Participant
0 Kudos

Have you checked the contents of the batch request? Is it actually loading these specific items or is it loading something else?

0 Kudos

In my view i have 8 multiInputs ,8 different entitysets,in batch all the 8 entitysets were loading.

Now handled that in controller .

Thanks

former_member322772
Active Participant
0 Kudos

Have you tried setting the startSuggestion property on the Input control in the XML view?

0 Kudos

Hi Luke,

I have added startSuggestion property ,but $batch request is loading all the items in the very first call from the app.

SergioG_TX
Active Contributor
0 Kudos

how many records (approx) is a large data amount?

have you tried making the odata call only after more than 1 char is entered?

what else is happening on your network? open the F12 developer tools and see if any other request is happening.

(any other operation?)

what is the performance on the end point view/table you are querying?