Style Cell for Table.addGeneratedColumn

What is the best approach to apply a style to cells of table for columns generated at runtime ?

Using setStyleProvider, I am not get values of columns generated at runtime.

customersTable.setStyleProvider((customer, property) -> {
        if (property == null) {
        // style for row
        if (hasComplaints(customer)) {
            return "unsatisfied-customer";
        }
    } 

Hi @fala70,

Unfortunately, the Table does not have an API to get the value of the generated cell.
I suggest creating a transient, meta property for this generated column.

  1. Add grade meta property to Customer entity
@Transient
@MetaProperty
protected Integer grade;
  1. Add generator for the grade column
public Component generateGrade(Customer entity) {
    CustomerGrade customerGrade = CustomerGrade.fromId(10);
    entity.setGrade(customerGrade);
    return new Table.PlainTextCell(customerGrade.name());
}
  1. Add a style provider for the grade column
@Install(to = "table", subject = "styleProvider")
protected String customerTableStyleProvider(Customer customer, String property) {
    if (property == null) {
        // style for row
    } else if (property.equals("grade")) {
        switch (customer.getGrade()) {
            case PREMIUM:
                return "premium-grade";
            case HIGH:
                return "high-grade";
            case MEDIUM:
                return "medium-grade";
        }
    }
    return null;
}

Regards,
Gleb

is not a solution for me. At this point is better style into column method