aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsReattach.java
blob: 8146edfffed675295e0322a10d5087b64c638913 (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
package com.vaadin.tests.components.grid;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;

public class GridDetailsReattach extends AbstractTestUI {

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

        final VerticalLayout layoutWithGrid = new VerticalLayout();

        Grid<String> grid = new Grid<>("Grid");
        grid.addColumn(String::toString).setCaption("Foo");
        grid.setHeight("150px");
        grid.setItems("Foo");
        grid.setDetailsGenerator(str -> new Label("AnyDetails"));
        grid.setDetailsVisible("Foo", true);
        layoutWithGrid.addComponent(grid);

        Button addCaptionToLayoutWithGridButton = new Button(
                "Add caption to 'layoutWithGrid' layout");
        addCaptionToLayoutWithGridButton
                .addClickListener(event -> layoutWithGrid.setCaption(
                        "Caption added to 'layoutWithGrid' layout"));
        layoutWithGrid.addComponent(addCaptionToLayoutWithGridButton);

        verticalMain.addComponent(layoutWithGrid);

        addComponent(verticalMain);

    }
}