on 2013 Dec 19 7:34 PM
Hello All
Have a json file(emp.json) which contains employee data, want to instantiate model in controller then want to make use in UI (bind it to ui form fields).
emp.json:
{
firstName: "John",
lastName: "Doe",
birthday: {day:01,month:05,year:1982},
address:[{city:"Heidelberg"}],
enabled: true
}
test.controller.js
var oModel = new sap.ui.model.json.JSONModel("model/std.json");
sap.ui.getCore().setModel(oModel);
test.view.js:
var oTxt = new sap.ui.commons.TextField("txtField", {
value: "{/firstName}"
});
But output data from file is not displaying in text field, Please correct me if i coded wrongly.
Thanks
Sri
Your JSON is invalid. If you've used that JSON as shown in your message above, you will probably be able to see an error in the console.
Problems with the JSON:
- the property names should be in double quotes
- the values 01 and 05 aren't accepted as numbers
Fix these issues and it should work fine.
I'm also assuming that you have matched the filenames (emp.json != std.json) 🙂
dj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello DJ
Thank you for reply.
Have take below json file but still not getting output.
model/std.json :
{
firstName: "John",
lastName: "Doe"
}
test.controller.js
var oModel = new sap.ui.model.json.JSONModel("model/std.json");
sap.ui.getCore().setModel(oModel);
test.view.js:
var oTxt = new sap.ui.commons.TextField("txtField", {
value: "{/firstName}"
});
Please tell me what is going wrong still .
Sri
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.