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: https://doc.cuba-platform.com/manual-6.8/gui_Table.html#gui_Table_addGeneratedColumn

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

1 Like

Thanks for the heads up!