TreeGrid width does not automatically adjust

Hello, I am using the business app starter as a “template” for my application, and I have added a TreeGrid to the Navigation Drawer, more precisely to the “scrollableArea” div.
I have set the size of the TreeGrid to setSizeFull(), but when I expand the items in the TreeGrid, the width does not adjust but stays the same, so the names of the items are cut off. I’ve tried setting the overflow, but it does not work, since the actual size of the TreeGrid does not change. For now I have set a fixed width, so the overflow scrollbar appears, but I would like the TreeGrid to adjust its width based on the expanded items.

Here is the code for initializing the TreeGrid (in NaviDrawer.java)

private void initTreeGrid(){
		treeGrid = new TreeGrid<>(TreeGridData.class);
		treeGrid.setSizeFull();
		treeGrid.setHeightByRows(true);
		treeGrid.setMinWidth("400px");
		treeGrid.addThemeNames("no-border", "no-row-borders", "row-stripes");
		treeGrid.getStyle().set("font-size", "0.8em");
		scrollableArea.add(treeGrid);
	}

I have attached the image of how it looks like currently (with the fixed width).
So what I would like to achieve is that the width expands according to the expanded items, so when no items are expanded, the bottom scrollbar should not be shown, but when the expanded items exceed the width of the drawer, the bottom scrollbar should show. I hope the explanation was clear.
Any help would be greatly appreciated.

Regards, Nemanja

18224159.png

Hi,

Currently it cannot be easily achieved. There is a feature request for this, which you can +1 in GitHub: https://github.com/vaadin/vaadin-grid/issues/1287.

Best regards