简体   繁体   English

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

[英]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.

相关问题 如何在XML文件中合并两个不同的路径? - How to merge two different paths in a XML file? 如何在PowerShell中将位于不同文件夹路径中的多个XML文件合并为一个XML文件? - How to merge multiple XML files located in different folder paths into one XML file in PowerShell? 如何在 PHP 中的一个元素中编写多个不同的 xml 命名空间 - How to write multiple different xml namespace in one element in PHP 如何在XStream或JAXB上将两个XML元素级别映射到一个级别? - How to map two XML element levels to one level on XStream or JAXB? 如何将xml元素绑定到对象成员变量中? - How to bind a xml element into an object member variable? 如何将两种不同的样式应用于android中的一个元素? - How to apply two different styles to one element in android? 检查XML是否具有两种不同类型的元素节点,如何使用XSLT将其引入输出XML - Check if XML has two different types of element node how to bring it in output XML using XSLT 如何在Groovy或Java中按元素“paths”过滤XML字符串 - How to filter XML string by element “paths” in Groovy or Java 两个不同的 POJO 编组到一个 XML - Two different POJO marshal to one XML 如何使 XML 元件与端元件不同? - How to make XML element different with end element?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM