on 02-17-2015 12:12 PM
Hi,
I'm working on SAPui5 ...
Im using a simple form layout and in that form i have input box as well as labels....using an odata service. Now what im looking forward is to try binding the input fields with the odata...
Can anyone advice me on how to do it inside a form??????
Thanks,
Ashwin
The way how you bind doesn't differ for the controls inside a simple form. Have a look at the sample code of the simple form in the explored app SAPUI5 Explored .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sakthivel,
I guess i need a bit more guidance regarding it....Will Post the code of view and Controller:
View
var oForm = new sap.ui.layout.form.SimpleForm("formid",
{
minWidth : 1024,
maxContainerCols:1,
editable: true,
title:"Trial",
content:[
new sap.m.Label({text :"ID", design : "Bold", textAlign : "Begin"}),
new sap.m.Input("id",{
width:"200px",
}),
new sap.m.Label({text : "Name",design : "Bold", textAlign : "Begin"}),
new sap.m.Input("name",{
width:"200px",
}),
new sap.m.Label({text : "Description", design : "Bold", textAlign : "Begin"}),
new sap.m.Input("description",{
width:"200px",
}),
new sap.m.Label({text:"Price"}),
new sap.m.Input("price",{
width:"200px",
}),
new sap.m.Label({text:"Rating"}),
new sap.m.Input("rating",{
width:"200px",
}),
new sap.m.Label({text:"ReleaseDate"}),
new sap.m.Input("date",{value:"2014-09-12T22:22:22",width:"200px"}),
new sap.m.Label({text:""}),
new sap.m.Button("save",{text:"Save",width:"120px",icon:"sap-icon://save",
press: function(){
oController.save();
}}),
]});
Controller
onInit: function() {
var oModel = sap.ui.model.odata.ODataModel("proxy/http/services.odata.org/V3/OData/OData.svc/");
oModel.oHeaders ={
"DataServiceVersion": "3.0",
"MaxDataServiceVersion":"3.0"
};
sap.ui.getCore().setModel(oModel, "products");
},
Added this without binding it to the controls. Service is an open odata service....
Please share your valuable comments to wards achieving binding.
Thanks,
Ashwin
As pointed by use from SAPUI5 Explored
this.getView().bindElement("/EntitySetName/0");
Hi Ashwin,
In controller
onInit: function() {
this.oModel = sap.ui.model.odata.ODataModel("proxy/http/services.odata.org/V3/OData/OData.svc");
this.oModel.oHeaders ={
"DataServiceVersion": "3.0",
"MaxDataServiceVersion":"3.0"
};
this.getView().setModel(this.oModel);
this.getView().bindElement("/Products(0)");
},
In View try to bind it to the control
new sap.m.Label({text :"ID", design : "Bold", textAlign : "Begin"}),
new sap.m.Input("id",{value : "{ID}",
width:"200px",
}),
regards
Indrajith
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.