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.

GridUndefinedHeight.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package com.vaadin.tests.components.grid;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.shared.ui.grid.HeightMode;
  4. import com.vaadin.tests.components.AbstractTestUI;
  5. import com.vaadin.ui.Button;
  6. import com.vaadin.ui.Grid;
  7. import com.vaadin.ui.VerticalLayout;
  8. public class GridUndefinedHeight extends AbstractTestUI {
  9. @Override
  10. protected void setup(VaadinRequest request) {
  11. VerticalLayout layout = new VerticalLayout();
  12. Grid<String> grid = new Grid<>();
  13. grid.setItems("Foo", "Bar", "Baz");
  14. grid.setHeightMode(HeightMode.UNDEFINED);
  15. grid.addColumn(Object::toString).setCaption("toString()");
  16. com.vaadin.v7.ui.Grid oldGrid = new com.vaadin.v7.ui.Grid();
  17. oldGrid.addColumn("toString", String.class);
  18. oldGrid.addRow("Foo");
  19. oldGrid.addRow("Bar");
  20. oldGrid.addRow("Baz");
  21. oldGrid.setHeightMode(
  22. com.vaadin.v7.shared.ui.grid.HeightMode.UNDEFINED);
  23. layout.addComponents(grid, oldGrid, new Button("Add header row", e -> {
  24. grid.appendHeaderRow();
  25. oldGrid.appendHeaderRow();
  26. }));
  27. layout.setHeight("600px");
  28. layout.setExpandRatio(grid, 1.0f);
  29. layout.setExpandRatio(oldGrid, 1.0f);
  30. addComponent(layout);
  31. }
  32. }