cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 Get entityset data to a variable

Ibrahem
Participant
0 Kudos

Dears,

I want to get entity set data to a variable using class "sap.ui.model.odata.v2.ODataModel" but always the variable value is undefined.

as I read OData v2 is loading data async but till now I don't have any clue how to load data into a variable.

//Creating the Model Instance
// "/destination/ODataTest" is defiended in my neo-app.json"
var oModel = new sap.ui.model.odata.v2.ODataModel("/destination/ODataTest/Northwind/Northwind.svc/");

var DataLoaded = oModel.read("/Products",
{success: function(){
    MessageToast.show("Success");
}, error: function(e){
    MessageToast.show("Failed");}
});

Thank you.

View Entire Topic
former_member192494
Participant
0 Kudos

Hi,

You could use the below method to see if metadata is loaded, post which you can check if the data is getting binded to your controls.

oDataModel.attachMetadataLoaded(function(){

var oMetadata = oDataModel.getServiceMetadata();

});

Regards,

Ravikiran