[英]XML view: How to bind two different paths to one element?
I am developing Fiori App to display some sales data, called from an OData Service. 我正在开发Fiori App,以显示一些销售数据,这些数据是从OData服务调用的。 I have a header (invoiceHeaderSet) with the field "Waerk" to display the currency key.
我有一个带有字段“ Waerk”的标题(invoiceHeaderSet),以显示货币键。
I have positions (/invoiceHeaderPositionsNav) bound to a table. 我有绑定到表的位置(/ invoiceHeaderPositionsNav)。 Now, I want to display the headers "Waerk" field next to each positions currency field "Netwr".
现在,我想在每个头寸货币字段“ Netwr”旁边显示标题“ Waerk”字段。
How can I do this in XML views without creating surplus local models? 如何在XML视图中执行此操作而不创建多余的本地模型? Below, you will see a simplified example of my problem.
在下面,您将看到我的问题的简化示例。
// this view is bound to OData /invoiceHeaderSet
<ObjectHeader
numberUnit="{Waerk}"/> <-- does work
<Table
items="{
path: 'invoiceHeaderPositionsNav'
}" />
<ColumnListItem
<Text text="{'Netwr'} <-- does work
{'/invoiceHeaderSet/Waerk'}"/> <-- does not work
Solution A 解决方案A
Did you activate the complex binding syntax in the bootstrapping part of your index.html? 您是否在index.html的引导部分中激活了复杂的绑定语法?
data-sap-ui-bindingSyntax="complex"
Solution B 解决方案B
What you could also do is writing your own formatter method. 您还可以做的是编写自己的格式化程序方法。 For that you have to change your binding to something like this:
为此,您必须将绑定更改为以下内容:
text="{ parts: [{ path: 'Netwr' }, { path: '/invoiceHeaderSet/Waerk' }], formatter: '.formatTitle' }"
And in your Controller you have to implement the formatTitle
function, eg 并且在您的Controller中,您必须实现
formatTitle
函数,例如
formatTitle: function (sNetwr, sWaerk) {
return sNetwr + " " + sWaerk;
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.