How to set table column visible dynamically

Hi,

I am using the below code but it is showing compile time error


List<String> selectedYears = Arrays.asList(selectedYearsList);
for (Table.Column c: seedAdoptionRootMapTable.getColumns()){
    if (!selectedYears.contains(c.getId().toString())){
        c.setVisible(false);
    }
}

Can anyone help here?

Hi,

There is no setVisible() method in Table.Column. If columns should be available for users - use Column.setCollapsed(true). If you want to remove columns completely - use table.removeColumn(column). In the first case users will be able to show them from column control menu at the top-right corner of a table.

A post was split to a new topic: Table setCollapsed does not work