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.

GridColumnsNoMinimumWidthFromContent.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.vaadin.tests.components.grid;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Random;
  5. import com.vaadin.server.VaadinRequest;
  6. import com.vaadin.tests.components.AbstractTestUI;
  7. import com.vaadin.ui.Grid;
  8. import com.vaadin.ui.components.grid.FooterRow;
  9. public class GridColumnsNoMinimumWidthFromContent extends AbstractTestUI {
  10. @Override
  11. protected void setup(VaadinRequest request) {
  12. Random random = new Random();
  13. List<DummyGridRow> gridRows = new ArrayList<DummyGridRow>();
  14. gridRows.add(new DummyGridRow(random));
  15. Grid<DummyGridRow> grid = new Grid<DummyGridRow>();
  16. for (int i = 0; i < 20; i++) {
  17. grid.addColumn(DummyGridRow::getValue)
  18. .setCaption("[" + i + "] Quite dummy column")
  19. .setMinimumWidthFromContent(false);
  20. }
  21. grid.setItems(gridRows);
  22. FooterRow defaultFooter = grid.appendFooterRow();
  23. grid.getColumns().forEach(column -> defaultFooter.getCell(column)
  24. .setText(grid.getDefaultHeaderRow().getCell(column).getText()));
  25. grid.setFooterVisible(true);
  26. grid.setHeightByRows(gridRows.size());
  27. grid.setWidthFull();
  28. getLayout().addComponent(grid);
  29. }
  30. class DummyGridRow {
  31. private Random random = null;
  32. public DummyGridRow(Random random) {
  33. this.random = random;
  34. }
  35. public int getValue() {
  36. return random.nextInt(1000000000);
  37. }
  38. }
  39. @Override
  40. protected Integer getTicketNumber() {
  41. return 12139;
  42. }
  43. @Override
  44. protected String getTestDescription() {
  45. return "Loading the UI should not get stuck in an eternal loop "
  46. + "and the columns should be narrow with ellipsis "
  47. + "until the page is resized small enough that "
  48. + "the resize handles alone force a scrollbar. "
  49. + "No overflowing of header cells should occur "
  50. + "when resized very near to the cutoff point "
  51. + "between no scrollbar and a scrollbar.";
  52. }
  53. }