Use setFormatter() but adjusted per row

Hey all,

I have a browse screen on an Order Entity, which has a String currencyCode ( USD, EUR, GBP), and an BigDecimal invoiceAmount.

On the invoiceAmount column I want to add a formatter, so I can add a currencySymbol before the amount.
But this currency differs per order. Does anyone know if it still is possible with the column formatter ?
The format method just takes the BigDecimal value as input, so I can’t dynamically change the currencySymbol.

  Formatter<BigDecimal> formatter = new Formatter<BigDecimal>() {
    @Nullable
     @Override
             public String format(@Nullable BigDecimal value) {
                 if (value != null) {
 
                     String format = currencySymbol + " " + value;
 
 
                     return format;
                 } else {
                     return null;
                 }
             }
         };
 
ordersTable.getColumn("invoiceAmount").setFormatter(formatter);

Hi,

At the moment it is possible only with generated columns: Table - CUBA Platform. Developer’s Manual

I’ve created the issue https://youtrack.cuba-platform.com/issue/PL-8554 in our bug tracker

1 Like

Thanks for the heads up!