cancel
Showing results for 
Search instead for 
Did you mean: 

Load oData in Json_Model...

0 Kudos

Hey Experts!

i want to get my oData from my HDBView via a json model.... in all my cases it works, but now i do not get even a single data from ma json model and i do not know why.

The view is working fine in the HDB, i get all my data i want via sql query in Hana Studio but not if i want to get these data into my json model.

I did screenshots how my code looks like:

A simple Json-Model with a filter-query:

And that is what my console puts out: -empty oData

even i do not use a filter query the model will be still empty, all my other model, also json model, are working these are build up the same way...

For your information, this json model is created after pressed on a button because i need to generate the "taskid" in this function, that´s why i did not instantiate it in my onRouteMatch() or in my onInit() function.

Thanks a lot for helping me!

Best regards,

Danilo

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Danilo,

May be you have to wait until request is completed and then set model? Try something like below and check:


var that = this;

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

oModel.loadData("yourURL");

oModel.attachRequestCompleted(function(oEvent){

     var oSource = oEvent.getSource();

     that.getView().setModel(oSource, "yourModelName");

});

Regards,

Sai.

0 Kudos

Thanks! Now its working fine 🙂

Answers (0)