You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GridDetailsReattach.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.vaadin.tests.components.grid;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractTestUI;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.Grid;
  6. import com.vaadin.ui.Label;
  7. import com.vaadin.ui.VerticalLayout;
  8. public class GridDetailsReattach extends AbstractTestUI {
  9. @Override
  10. protected void setup(VaadinRequest request) {
  11. final VerticalLayout verticalMain = new VerticalLayout();
  12. final VerticalLayout layoutWithGrid = new VerticalLayout();
  13. Grid<String> grid = new Grid<>("Grid");
  14. grid.addColumn(String::toString).setCaption("Foo");
  15. grid.setHeight("150px");
  16. grid.setItems("Foo");
  17. grid.setDetailsGenerator(str -> new Label("AnyDetails"));
  18. grid.setDetailsVisible("Foo", true);
  19. layoutWithGrid.addComponent(grid);
  20. Button addCaptionToLayoutWithGridButton = new Button(
  21. "Add caption to 'layoutWithGrid' layout");
  22. addCaptionToLayoutWithGridButton.addClickListener(e -> layoutWithGrid
  23. .setCaption("Caption added to 'layoutWithGrid' layout"));
  24. layoutWithGrid.addComponent(addCaptionToLayoutWithGridButton);
  25. verticalMain.addComponent(layoutWithGrid);
  26. addComponent(verticalMain);
  27. }
  28. }