on 2017 Sep 03 6:11 PM
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.
For sharing, I found a solution by reading SAP standard app after importing it from ABAP repository to web IDE
var DataLoaded = oModel.read("/Products",
{success: function(response){
//response will have the retrun of the request
console.log(response.results);
MessageToast.show("Success");
}, error: function(e){
MessageToast.show("Failed");}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
looks like your destination url is missing " right after the ( on the new model creation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
13 | |
10 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.