Skip to Content

No Data in JSON model - Local Model

Dear All ,

I have created a JSON model and trying to load data from a manually created file in eclipse. Below is the code and file I have created Eclipse project.

var oCondModel = new sap.ui.model.json.JSONModel("model/mock.json");

But I am unable to load data into to the model always oCondModel is producing balnk model.

What could be the cause...


JSON Load.PNG (8.7 kB)
oData.PNG (26.4 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2015 at 10:08 AM


    Can you post your code? Otherwise it's pretty difficult to see where the problem is...



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 01, 2015 at 10:40 AM

    You are missing a slash: .JSONModel("/model/mock.json");

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 01, 2015 at 10:49 AM

    did you sent that model to your view,

    var oView = sap.ui.view({

    id : "app",

    viewName : "VIEW_PATH",

    type : "JS",

    viewData : { component : this }


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


    Add a comment
    10|10000 characters needed characters exceeded

    • This code works (and should work since it is correct):

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

      currencyModel.loadData("/model/moedas.json", '', false);

      This of course assumes that the Resource Root is correct in the Index.html:

      data-sap-ui-resourceroots='{"X": "./"}'>

      Where X is the full qualified name of the sap.ui.core.ComponentContainer.

  • Posted on Apr 01, 2015 at 11:05 AM

    Hi Santhosh,

    I think You are showing me the "green light" to sort this out.

    Actually I am using oData services from Gateway Server and that is working fine with JSON models in my View.

    I am using this Local JSON model (created in "model" folder and named as "mock.json as mentioned above) for a few reason.

    I haven't created this in my view as you said.

    I am using several views in my project and calling this JSON model in a defined method in the oController in that particular view (ex : View name : "po_change.SelectItem" ) .

    Can you just tell me why and How you bind this model into the view?

    Add a comment
    10|10000 characters needed characters exceeded

    • Above model is create as a local model for offline development.

      and i'm using oData model for getting the data from the server then using local json model i'm doing data binding.


      var oModelData = new sap.ui.model.odata.ODataModel(sUrl, false);


      this.setModel(oModelData, "odata");

      so, in my view using odata>AttributeName binding to text.

      In controller,

      var oModelData = sap.ui.getCore().getModel();

      var url = oModelData.url+"/extendedURL";

      creating local model and doing binding.

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.