简体   繁体   中英

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. I have a header (invoiceHeaderSet) with the field "Waerk" to display the currency key.

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

How can I do this in XML views without creating surplus local models? 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

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

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, eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM