Skip to Content
0
Former Member
Dec 19, 2013 at 07:34 PM

Data through JSON file

40 Views

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