I have a TreeGrid with 2 component columns. The first component column contains a HorizontalLayout with a Label and a Button. The second component column contains a HorizontalLayout with a Button. I was not able to right align the Button in the first component column. Is it doable? If it is not doable, do you have any workaround suggestions? My constraints are the TreeGrid, the 2 columns and that the first column should contain a Label and a right aligned Button. What i tried so far
TreeGrid<Object> treeGrid = new TreeGrid<>();
treeGrid.setSizeFull();
treeGrid.addComponentColumn(vp -> {
Button button = new Button("button");
HorizontalLayout cell = new HorizontalLayout(new Label("label"), button);
cell.setSizeFull();
cell.setExpandRatio(button, 1.0f);
cell.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);
return cell;
}).setCaption("st column").setExpandRatio(1).setId("st column");
treeGrid.addComponentColumn(vp -> new HorizontalLayout(new Button("some other button")))
.setCaption("nd column").setId("nd column").setWidth(200.0d);
TreeData<Object> objectTreeData = new TreeData<>();
objectTreeData.addRootItems(new Object());
treeGrid.setDataProvider(new TreeDataProvider<>(objectTreeData));
window.setContent(treeGrid);
UI.getCurrent().addWindow(window);
window.center();
window.setWidth("40%");
window.setHeight("40%");