alwaysRecalculateColumnWidths = true doesn't work for new items created thr

Hi all,
The experimental feature
works fine when adding items through a button:

  • A new item will be added with a larger text
  • The column gets as large as the text
  • A scrollbar is show as the columns don’t fit in the table width.
    See the attachment ClickButton.jpg

But when adding an item through a node expand listener (click on the expand icon) then the column widths won’t be recalculated:

  • A new item will be added with a larger text
  • The column should also get as large to fit the text, but that isn’t the case. The column width stays the same.
    See the attachment ExpandNode.jpg

Here a full example:

package com.example.autoscaletest;

import com.vaadin.annotations.Theme;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Tree.ExpandEvent;
import com.vaadin.ui.Tree.ExpandListener;
import com.vaadin.ui.TreeTable;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

public class AutoscaletestUI extends UI {

protected static final String FIRST = "first";
protected static final String SECOND = "second";
private TreeTable tt;

protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();

    tt = new TreeTable() {
            alwaysRecalculateColumnWidths = true;
    tt.addContainerProperty(FIRST, String.class, "");
    tt.addContainerProperty(SECOND, String.class, "");
    // Column doesn't get larger
    tt.addExpandListener(new ExpandListener() {
        public void nodeExpand(ExpandEvent event) {
            addItem(FIRST + FIRST + FIRST);
    // Column gets larger
    Button button = new Button("Add item");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            addItem(FIRST + FIRST + FIRST);

private void addItem(String text) {
    Object addItem = tt.addItem();
    Item item = tt.getItem(addItem);

[/code]What has to be done to get the column larger when pressing the expand icon?

Any help is appreciated :slight_smile:

Did you find a solution to this? I’ve just encountered the same thing - column widths are calculated based on the root items, and don’t change when you expand them. Making a change to one of the newly expanded children does cause a resize, however.