aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/grid/GridUndefinedHeight.java
blob: 35ca7a06249785b60e72bafa787f4d7199ecb23c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.vaadin.tests.components.grid;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.grid.HeightMode;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Grid;
import com.vaadin.ui.VerticalLayout;

public class GridUndefinedHeight extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        VerticalLayout layout = new VerticalLayout();

        Grid<String> grid = new Grid<>();
        grid.setItems("Foo", "Bar", "Baz");
        grid.setHeightMode(HeightMode.UNDEFINED);
        grid.addColumn(Object::toString).setCaption("toString()");

        com.vaadin.v7.ui.Grid oldGrid = new com.vaadin.v7.ui.Grid();
        oldGrid.addColumn("toString", String.class);
        oldGrid.addRow("Foo");
        oldGrid.addRow("Bar");
        oldGrid.addRow("Baz");
        oldGrid.setHeightMode(
                com.vaadin.v7.shared.ui.grid.HeightMode.UNDEFINED);

        layout.addComponents(grid, oldGrid,
                new Button("Add header row", event -> {
                    grid.appendHeaderRow();
                    oldGrid.appendHeaderRow();
                }));
        layout.setHeight("600px");
        layout.setExpandRatio(grid, 1.0f);
        layout.setExpandRatio(oldGrid, 1.0f);
        addComponent(layout);
    }

}