Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9760

Re: How to load data from model before showing table?

$
0
0

I got the solution .

Create ODataModel instance using path to the set of services as follows:

 

var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSECENTRAL_SRV",true);

 

then to get the data from a particular service make a call as follows:

 

oModel.read("/FAVOURITESet",null, null, true, function(data,d1,d2){console.log(data);},function(){alert("Fail");});

 

This retrieves data. If we don't specify the success call back then by default it pops up the response.

 

Giving flashback to my question, when a table has a model set and have rows bound with some path as follows:

 

new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSECENTRAL_SRV", true);

oTable.setModel(oModel);

oTable.bindRows("/FAVOURITESet",true);

oTable.setVisible(false);

return oTable;

 

In this case, if we try to get the data as follows, it fails:

 

oTable.getModel().oData; // this returns null

 

and the data is retrieved only when the oTable is made visible and till the time it is made visible, we don't get to see any data in the response in 'Network' tab of the browser.

 

So the solution is to use the code shown in bluewhen we don't want to tie data from a service with particular control.

 

 

Thanks,

Supriya Kale


Viewing all articles
Browse latest Browse all 9760

Trending Articles