我们必须将 OData url 绑定到 UI5 的 ODataModel
https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV/BusinessPartners ('0100000000')/SalesOrders/?$expand=SalesOrderItems
我们能够绑定属于每个 SalesOrder 的根级别项目。但是,如果将子数据绑定SalesOrderItems
到SalesOrder
.
我们无法将 SalesOrderItems 的字段绑定到我们的任何对象。我们尝试使用{SalesOrderItems/results/QuantityUnit}
,{SalesOrderItems/QuantityUnit}
但运气不佳。
你能建议任何替代方案吗?
SalesOrder 和 SalesOrderItem 之间有 1..m 基数
// model of oData
var model = sap.ui.model.odata.ODataModel("proxy/https/sapes1.sapdevcenter.com/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV/",true,'username','password');
//app is defined in index.html here we are setting model to the app.
App.setModel(model);
// create a table
var pastOrder_S3= new sap.m.Table("PastOrder_S3",{
inset:true,
//visibleRowCount: 2,
firstVisibleRow: 2,
fixedColumnCount: 2,
columns:[
new sap.m.Column({
header:new sap.m.Label("item").setText("Items"),
hAlign:"Left",
width:"20px",
demandPopin:true,
popinDisplay:"Block",
minScreenWidth: sap.m.ScreenSize.Medium
}),
new sap.m.Column({
header:new sap.m.Label("orderdetail").setText("OrderDetails"),
hAlign:"Left",
width:"200px",
demandPopin:true,
popinDisplay:"Block",
minScreenWidth: sap.m.ScreenSize.Medium
})
});
//create a template to bind into the table using model.
var oTemplate_S3= new sap.m.ColumnListItem({
type: sap.m.ListType.Active,
cells: [
new sap.m.Text({
text:"{ProductName} \n {ProductID}"
}),
new sap.m.Text({
text:"OrderId: {SalesOrderID} \n {DeliveryDate} \n {TotalSum}{Currency}"
})
]
});
// bind into the table.
`pastOrder_S3.bindAggregation("items","BusinessPartners('BusinessPartnerId')/SalesOrders/?$expand=SalesOrderItems",oTemplate_S3);`
这里我们有一个名为“SalesOrderItems”的子属性,我们需要读取salesorderitems 中的属性。