on 01-27-2015 9:41 PM
Hi,
I have a odata model. Whenever the function is called, the request gets sent twice. Here is my code
populateTable:function(SalesOrg, FiscalYear, FiscalPeriod, CustomerHierarchy1, ProductLine, searchFilter){
var oRowTemplate = new sap.m.ColumnListItem({
cells : [
new sap.m.Text({text : "{CustomerHierarchy1}" }),
new sap.m.Text({text : "{ProductFamily}"})
]}
);
var oTable =this.getView().byId("populateTable");
oTable.bindItems({
path: URL.populateTable.entity,
template:oRowTemplate
});
var oModel = new sap.ui.model.odata.ODataModel(URL.populateTable.service, true);
alert(oModel);
oTable.setModel(oModel);
}
The alert is popped up only once. However, the request is twice. Everything including the URL parameters and response are same.
Please find the code here. JS Bin - Collaborative JavaScript Debugging
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oModel.setDefaultCountMode(sap.ui.model.odata.CountMode.None);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
so, populateTable is executed twice. set a breakpoint there and see a stack trace (or post screenshots of both here 😉 )
btw, creating an odata model is pretty heavy opertion as it includes donwloading and parsing metadata so i would not do it in a "business" methods rather in init/onInit of components/controllers
The function is getting executed only once. I tested with both alert and console.log My use case is,
I have to load the first 10 rows out of 1 million rows. When the user clicks on more button, I hit the server and retrieve the next 10 rows. For this use case, I thought we can only use odata model.
just
oTable.setGrowingThreshold(10) and sap.m.Table will take care of the rest (OData query options $top and $skip)
is the entire request completed??? look into the chrome developer tools and you will see if the request is truly being completed x many times. at most one request is completed but maybe many will fire.
check the developer tools and let us know your findings
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
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.