Hello,
We are unable to bind OData response to a form. Upon checking the "network" tab in chrome browser, we are able to see the JSON response. Please let us know if something is wrong in our approach. Just to add here, we were able to bind OData to list and bind JSON to a form, but while binding OData to a form we are stuck.
SNIPPET FROM CONTROLLER JS:
var url = | "******** the ODATA SERVICE URL ***********"; |
var oModel = new sap.ui.model.odata.ODataModel(url, true);
this.getView().setModel(oModel);
// Set the initial form to be the change one
var oForm = this._getFormFragment("Display");
this.getView().byId("idFormContainer").insertContent(oForm);
//this.getView().bindElement("/BP_DETAILSSet",{ custom: { "TelnrCall" : "9926188375" }});
oForm.bindElement("/BP_DETAILSSet",{ custom: { "TelnrCall" : "9926188375" }});
FORM FRAGMENT:
<core:FragmentDefinition xmlns="sap.m" xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form" xmlns:core="sap.ui.core">
<l:Grid defaultSpan="L12 M12 S12" width="auto">
<l:content>
<f:SimpleForm id="SimpleFormDisplay480" minWidth="1024"
maxContainerCols="2" editable="false" layout="ResponsiveGridLayout"
title="Address" labelSpanL="4" labelSpanM="4" emptySpanL="0"
emptySpanM="0" columnsL="2" columnsM="2" >
<f:content>
<core:Title text="Office" />
<Label text="Name" />
<Text text="{NameFirst} {NameLast}" />
<Label text="Street/No." />
<Text text="{Street} {HouseNum1}" />
<Label text="ZIP Code/City" />
<Text text="{PostCode1} {City1}" />
<Label text="Country" />
<Text text="{Country}" />
<core:Title text="Online" />
<Label text="Email" />
<Text text="{SmtpAddr}" />
<Label text="Cell" />
<Text text="{TelnrCall}" />
</f:content>
</f:SimpleForm>
</l:content>
</l:Grid>
</core:FragmentDefinition>
JSON RESPONSE:
{
"d": {
"results": [
{
"PostCode1": "WC2A1AD",
"Country": "GB",
"City1": "London",
"Street": "Chanchery Ln",
"HouseNum1": "10",
"TelnrCall": "9926188375",
"TelNumber": "123456789",
"SmtpAddr": "john.major@gmail.com",
"NameLast": "Major",
"NameFirst": "John",
"Partner": "100000020"
}
]
}
}