XML视图:如何将两个不同的路径绑定到一个元素?

时间:2022-10-11 12:16:36

I am developing Fiori App to display some sales data, called from an OData Service. I have a header (invoiceHeaderSet) with the field "Waerk" to display the currency key.

我正在开发Fiori App以显示一些销售数据,这些数据来自OData服务。我有一个标题(invoiceHeaderSet),字段“Waerk”显示货币键。

I have positions (/invoiceHeaderPositionsNav) bound to a table. Now, I want to display the headers "Waerk" field next to each positions currency field "Netwr".

我有一个绑定到表的位置(/ invoiceHeaderPositionsNav)。现在,我想在每个位置货币字段“Netwr”旁边显示标题“Waerk”字段。

How can I do this in XML views without creating surplus local models? Below, you will see a simplified example of my problem.

如何在不创建多余本地模型的情况下在XML视图中执行此操作?下面,您将看到我的问题的简化示例。

// 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               

1 个解决方案

#1


0  

Solution A

Did you activate the complex binding syntax in the bootstrapping part of your index.html?

您是否在index.html的bootstrapping部分中激活了复杂的绑定语法?

data-sap-ui-bindingSyntax="complex"

Solution 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, e. g.

在Controller中,你必须实现formatTitle函数,e。 G。

formatTitle: function (sNetwr, sWaerk) {
    return sNetwr + " " + sWaerk;
},

#1


0  

Solution A

Did you activate the complex binding syntax in the bootstrapping part of your index.html?

您是否在index.html的bootstrapping部分中激活了复杂的绑定语法?

data-sap-ui-bindingSyntax="complex"

Solution 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, e. g.

在Controller中,你必须实现formatTitle函数,e。 G。

formatTitle: function (sNetwr, sWaerk) {
    return sNetwr + " " + sWaerk;
},