on 02-17-2016 12:18 PM
Hi All,
After creating a JSON model and loading data on it, i still cannot get the value inside that json object. My code is
var dataPath = "/test/medium.json";
var oModel = new sap.ui.model.json.JSONModel();
oModel.loadData(dataPath);
When i try to print the contents inside the json object, it returns as undefined. The code i use to get object contents is:
alert(oModel.getData());
Can someone please comment on what i missing in my code. Thanks in advance!
it is async by default, that's why you cannot get the data immediately.
try oModel.loadData(dataPath,"",false);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Abinsh,
your code looks alright. Make sure you have a json response on the relative url you specified for your JSON model. If the url is correct, then there may be an issue on how you create the JSON model itself.
try:
var path = "<YOUR_PATH>";
var oModel = new sap.ui.model.json.JSONModel(path);
// see if you have data at this point ... this may be the issue due to the correct way to specify the url
here is the documentation
also you should look at how the setData property of the model is being used on the controls tab
good luck
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.