Skip to Content
1
Nov 13, 2020 at 10:31 AM

Sapui5 Expression Binding - get a property of the last position of an array

287 Views Last edit Nov 13, 2020 at 11:11 AM 4 rev

Hello all. I have a problem with a binding expression in a column of a table (sap.ui.table).

Currently my column points to a property of the first position of an array (results/0/cust_Date):

<Column>
   <m:Label text="Date"/>
  <template>
      <m:Text text="{path:'externalCodeOfcust_PRLRMNav/results/0/cust_Date', formatter:'.formatter.convertDate'}" wrapping="false"/>
  </template>
</Column>

but now I want to point to a property of the last position of the array (results/...results.length-1/cust_Date).

For this I have tried many combinations of this type:

<Column>
  <m:Label text="Date"/>
<template>
    <m:Text text="{path:'externalCodeOfcust_PRLRMNav/results/{= ${externalCodeOfcust_PRLRMNav/results}.length-1}/cust_Date', formatter:'.formatter.convertDate'}" wrapping="false"/>
</template>
</Column> 

With this binding expression:

{= ${externalCodeOfcust_PRLRMNav/results}.length-1}

I can get the length of the array and then with -1 to know the last position, but when I combine it with the rest of the path to get the cust_Date property, it doesn´t work. Do you know how I could do it?

Thanks in advance. Best Regards