on 10-22-2018 4:32 PM
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);
}
},
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you checked the contents of the batch request? Is it actually loading these specific items or is it loading something else?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried setting the startSuggestion property on the Input control in the XML view?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.