我通过路径Northwind Customers('ANATR')/Orders获得了oData 我无法将其绑定到表客户订单
在这里,我有isdecimal
,就像在oData链接中一样
OrderList.controller.js
/Customers('" + oArgs.customerId + "')/Orders
在这里,我将其链接为绑定数据sap.ui.define([
"sap/ui/demo/nav/controller/BaseController"
], function (BaseController) {
"use strict";
return BaseController.extend("sap.ui.demo.nav.controller.customer.OrderList", {
onInit: function () {
var oRouter = this.getRouter();
oRouter.getRoute("customer").attachMatched(this._onRouteMatched, this);
},
_onRouteMatched : function (oEvent) {
var oArgs, oView;
oArgs = oEvent.getParameter("arguments");
oView = this.getView();
oView.bindElement({
path : "/Customers('" + oArgs.customerId + "')/Orders",
events : {
change: this._onBindingChange.bind(this),
dataRequested: function (oEvent) {
oView.setBusy(true);
},
dataReceived: function (oEvent) {
oView.setBusy(false);
}
}
});
}
});
});
,如何插入{path : '/Orders'}
参数?
OrderList.view.xml
{CustomerID}
答案 0 :(得分:1)
path : '/Orders'
是绝对绑定(以斜杠开头)。这意味着UI5将尝试获取https://services.odata.org/V2/Northwind/Northwind.svc/Orders
。
您还可以将视图绑定到事物列表。通常,这不是您想要的。
您想要的是将视图绑定到单个Customer实体
oView.bindElement({
path : "/Customers('" + oArgs.customerId + "')",
events: {
...
}
});
,然后对订单使用相对绑定(开头没有斜线):
items="{
path : 'Orders'
}"