Uncollapsed table column does not take available width

When a table is initially rendered, its column widths are calculated based on the data displayed in the table. But when the user chooses to add a column to the view (by “uncollapsing” one), it seems that Vaadin does not consider the data in that column to recalculate the column widths. As a result, some of the data in the added column is truncated, in spite of lots of left-over space. When I hit F5 in my browser, apparently the table rerendered, and this time the table looks like I want it, with column widths calculated based on data in all of the columns, including the previously collapsed one.

This is the code I used:

public class App extends Application {
    public void init() {
        IndexedContainer container = new IndexedContainer();
        container.addContainerProperty("ID", String.class, null);
        container.addContainerProperty("NAME", String.class, null);
        container.addContainerProperty("STREET", String.class, null);
        container.addContainerProperty("CITY", String.class, null);

        Table table = new Table();
        table.setColumnCollapsed("STREET", true);

        table.addItem(new Object[] {"HOMER", "Homer Simpson", "Evergreen Terrace", "Springfield"}, 1);
        table.addItem(new Object[] {"STAN", "Stan Marsh", "Avenue de los Mexicanos", "Southpark"}, 2);
        table.addItem(new Object[] {"PETER", "Peter Griffin", "Spooner Street", "Quahog"}, 3);

        Window mainWindow = new Window("Uncollapsed table column does not take available width");

The question is: Is there some programmatic way to force a table rerendering like F5 apparently does? I am using my own column selector (not the Vaadin one in the upper right corner of the table), so I can stick whatever I like in there. Things I already tried: requestRepaint, refreshRowCache, enableContentRefreshing.



This solved it for me:

        Table table = new Table() {
            {alwaysRecalculateColumnWidths = true;}