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

Re: JSONModel not loading from URL

$
0
0

I had the same issue. Of some reason the “data” is coming empty.

 

console.log(data);  would not work

 

Instead of using the "data parameter" the json data can be retrieved through the oModel after attachRequestCompleted has been called or by using this.

 

Example json fetched from the back-end

 

[{"id":1,"address":"My address1"},{"id":2,"address":" My address1"}]

 

var oModel = new sap.ui.model.json.JSONModel("URL");

  

    oModel.attachRequestCompleted(function(data) {

 

       //Print out the json data to the console into a table format using this    

    console.table(this.oData);

 

    //Update the structure

       oModel.setData({modelData: oModel.oData});

 

       //Retrieve individual value direct trough oModel

       console.log("Address::"+ oModel.getProperty("/modelData/0/address"));

 

});


Viewing all articles
Browse latest Browse all 3585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>