cancel
Showing results for 
Search instead for 
Did you mean: 

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

jorta
Participant
2,546

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

View Entire Topic
jorta
Participant
0 Kudos

Thank you very much Sergei.

That has worked for me with that binding:

<m:Text text="{= ${externalCodeOfcust_PRLRMNav/results}[ ${externalCodeOfcust_PRLRMNav/results}.length-1 ].cust_Date'}" wrapping="false"/>


, but it doesn't work for me with a binding with path (for formatting):

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


Would you know why?

sergei-u-niq
Active Contributor
0 Kudos

you either use expression binding, or you use a formatter. you could see it that way: expression binding is an in-place-formatter.