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.

GridScrollWithoutRows.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package com.vaadin.tests.components.grid;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import com.vaadin.server.VaadinRequest;
  5. import com.vaadin.tests.components.AbstractTestUI;
  6. import com.vaadin.ui.Button;
  7. import com.vaadin.ui.Grid;
  8. import com.vaadin.ui.Grid.SelectionMode;
  9. /**
  10. * There is no corresponding TB test as this problem can only be reproduced
  11. * using SuperDevMode.
  12. */
  13. public class GridScrollWithoutRows extends AbstractTestUI {
  14. private int counter = 0;
  15. @Override
  16. protected void setup(VaadinRequest request) {
  17. List<Integer> data = new ArrayList<>();
  18. Grid<Integer> grid = new Grid<>();
  19. grid.addColumn(Integer::valueOf).setCaption("ID").setId("id");
  20. grid.addColumn(Integer::valueOf).setCaption("FOO").setId("foo");
  21. grid.setItems(data);
  22. grid.setSelectionMode(SelectionMode.NONE);
  23. grid.setWidth("250px");
  24. grid.setHeightByRows(3);
  25. addComponent(grid);
  26. addComponent(new Button("Add row", e -> {
  27. data.add(counter);
  28. ++counter;
  29. grid.getDataProvider().refreshAll();
  30. }));
  31. Button beginningButton = new Button("Scroll to beginning", e -> {
  32. grid.scrollToStart();
  33. });
  34. beginningButton.setId("beginning");
  35. addComponent(beginningButton);
  36. Button endButton = new Button("Scroll to end", e -> {
  37. grid.scrollToEnd();
  38. });
  39. endButton.setId("end");
  40. addComponent(endButton);
  41. }
  42. @Override
  43. protected String getTestDescription() {
  44. return "It should be possible to scroll to beginning or end without assertion errors "
  45. + "even when there are no rows (requires SuperDevMode).";
  46. }
  47. @Override
  48. protected Integer getTicketNumber() {
  49. return 11558;
  50. }
  51. }