Skip to Content

Load oData in Json_Model...

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

json.PNG (51.0 kB)
console.PNG (59.7 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 26, 2016 at 12:07 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.