在订单over view 页面获取ODATA MODEL oModelView ,然后调用read function读取odata 的值,”/CVIEWSet"用于页面配置;订单的model ”salesOrder",关键代码如下:
oModelView.read( "/CVIEWSet",null,null,true,function(oData) {
for (var i = 0; i < oData.results.length; i++) { console
.log(oData.results[i].Name);
var sLable = "label."
+ oData.results[i].Name
+ "."
+ oData.results[i].Property;
switch (oData.results[i].Name) {
case "HEADER":
if (oData.results[i].Container == "FORM") {
var sFormId = sname
+ "."
+ oData.results[i].Name
+ "."
+ oData.results[i].Container;
// var oForm =
// oView.byId(sFormId);
sFormid = sFormId;
var oItems = oVbox
.getItems();
if (!isCon(oItems,
sFormId)) {
var layout = "{i18n>formLayout}";
var SpanL = 2; // "{i18n>labelSpanL}";
var SpanM = 2; // "{i18n>labelSpanM}";
var eSpanL = 0; // "{i18n>emptySpanL}";
var eSpanM = 0; // "{i18n>emptySpanM}";
var cSpanL = 2; // "{i18n>columnsL}";
var cSpanM = 2; // "{i18n>columnsM}";
var oForm = new sap.ui.layout.form.SimpleForm(
{
id : sFormId,
editable : true,
// layout
// :
// "{i18n>formLayout}",
layout : layout,
title : "抬头信息",
labelSpanL : SpanL,
labelSpanM : SpanM,
emptySpanL : eSpanL,
emptySpanM : eSpanM,
columnsL : cSpanL,
columnsM : cSpanM
});
oVbox
.addItem(oForm);
}
;
switch (oData.results[i].UiType) {
case "sap.m.Input":
if (oData.results[i].Property == "Guid") {
continue;
}
;
var sInput = oData.results[i].Name
+ "."
+ oData.results[i].Property;
oForm
.addContent(new sap.m.Label(
{
id : sLable,
text : oData.results[i].PropLabel
}));
var spath = ‘salesOrder>’
+ oData.results[i].Property;
oForm
.addContent(new sap.m.Input(
{
id : sInput,
value : "{"
+ spath
+ "}",
valueLiveUpdate : true,
description : "{"
+ spath
+ "}"
}));
break;
default:
break;
}
}
;
break;