How to bind json data to form.Below is my form and data to be binded. Please help me with this. Example i want to bind 111 object values to the form
Data:
{"customerdetailsjson": {
"111": [
{
"name": "Bhuvaneswari Krishnan",
"phone-number":"8050231233"
}
],
"112": [
{
"name":"Chetan Sandeep Renu",
"phone-number":"9840321321"
}
]
}}
Form:
var oLayout1 = new sap.ui.layout.form.ResponsiveGridLayout();
customerDetailsForm = new sap.ui.layout.form.Form("F1", {
layout: oLayout1,
formContainers: [new sap.ui.layout.form.FormContainer("F1C2", {
title: new sap.ui.core.Title({
text: "Address Information",
tooltip: "Address data"
}),
formElements: [new sap.ui.layout.form.FormElement({
label: "Street / Number",
fields: [new sap.m.Input({
type: sap.m.InputType.Text,
value: "{name}",
layoutData: new sap.ui.core.VariantLayoutData({
multipleLayoutData: [new sap.ui.layout.ResponsiveFlowLayoutData({
weight: 5
}), new sap.ui.layout.form.GridElementData({
hCells: "5"
})]
})
})]
}), new sap.ui.layout.form.FormElement({
label: "Street / Number",
fields: [new sap.m.Input({
type: sap.m.InputType.Text,
value: "{phone-number}",
layoutData: new sap.ui.core.VariantLayoutData({
multipleLayoutData: [new sap.ui.layout.ResponsiveFlowLayoutData({
weight: 5
}), new sap.ui.layout.form.GridElementData({
hCells: "5"
})]
})
})]
})]
})]
})]
First of all you need a model:
Then you assign it to your control:
Now you can start binding values from your model to the control (and also sub-controls) by using an absolute path from the root node of your model:
GL Chris