带有网格组件的Horizo​​ntalLayout#setFlexGrow不起作用(Vaadin 11.0.0)

时间:2018-09-10 16:11:17

标签: flexbox vaadin vaadin-flow

我有一个HorizontalLayout,其中包含两个Grid组件。 setFlexGrow设置将被忽略(请注意,如果将Grid替换为Div组件,它将像预期的那样工作)

@Route
@Theme(Lumo.class)
public final class TestView extends VerticalLayout {

    public TestView() {
        HorizontalLayout layout = new HorizontalLayout();
        layout.getStyle().set("border", "1px dashed #9E9E9E");
        layout.setWidth("100%");

        Component c1 = createComponent(1, "red");
        Component c2 = createComponent(2, "blue");
        layout.setFlexGrow(1, c1);
        layout.setFlexGrow(5, c2);
        layout.add(c1, c2);

        add(layout);
    }

    private Component createComponent(int id, String color) {
        Grid<String> c = new Grid<>();
        c.getStyle().set("border", "1px solid " + color);
        c.addColumn(o -> o).setHeader("C" + id);
        return c;
    }

}

结果:

enter image description here

DivComponent的结果:

enter image description here

0 个答案:

没有答案