Exclude property from bean item container (or prevent table from hitting ge

I have table with BeanItemContainer as datasource.
The issue is Some entity has getter which hits DB and returns huge amount of data.
And when I bound container to table, then formatPropertyValue in Table is called for each getter.
In my table column with this property isn’t shown, so this causes some lags without any profit.
Can I prevent table to use this getter.
Now I have some ways to fix it:

  1. Extend table and override formatPropertyValue
  2. Use Indexed container instead of BeanItemContainer and just don’t add this property to container.

#1 seems fine, but I wonder, is there any another way to exclude some property from being formatted by table?


setVisibleColumns must be called after setContainerDatasource()
And formatValue is called during setContainerDatasource.
So, this won’t help. :frowning:

What about com.vaadin.ui.Table.setContainerDataSource(Container, Collection<?>) ?

One of the best ways to format a property in Table is to use a concept (and interface) called ColumnGenerator and addGeneratedColumn(String, ColumnGenerator) method. With it you can replace existing property/column. You can return just String or even a Component instance if you want to display something more complex (think e.g. small pie chart or component to edit the underlaying value).