【发布时间】:2021-06-01 20:24:39
【问题描述】:
我有一个包含 2 个组件列的 TreeGrid。第一个组件列包含一个带有标签和按钮的 HorizontalLayout。第二个组件列包含一个带按钮的 HorizontalLayout。我无法右对齐第一个组件列中的 Button。可行吗?如果它不可行,您有任何解决方法建议吗?我的约束是 TreeGrid,两列,第一列应该包含一个标签和一个右对齐的按钮。 到目前为止我尝试了什么
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%");
【问题讨论】: