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.

HeaderSyncOnScroll.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractReindeerTestUI;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.HorizontalLayout;
  6. import com.vaadin.v7.ui.Table;
  7. public class HeaderSyncOnScroll extends AbstractReindeerTestUI {
  8. private Table table;
  9. @Override
  10. protected String getTestDescription() {
  11. return "Headers should be in sync when scrolling";
  12. }
  13. @Override
  14. protected Integer getTicketNumber() {
  15. return 17947;
  16. }
  17. @Override
  18. protected void setup(VaadinRequest request) {
  19. table = new Table();
  20. table.setWidth("400px");
  21. table.setHeight("300px");
  22. table.setPageLength(40);
  23. table.setFooterVisible(true);
  24. for (int i = 1; i < 11; i++) {
  25. String propertyId = "Property " + i;
  26. table.addContainerProperty(propertyId, String.class, null);
  27. if ((i - 1) % 2 == 0) {
  28. table.setColumnFooter(propertyId, "FOOTER " + i);
  29. }
  30. }
  31. for (int i = 0; i < 80; i++) {
  32. table.addItem(new String[] { "item " + i + "1", "item " + i + "2",
  33. "item " + i + "3", "item " + i + "4", "item " + i + "5",
  34. "item " + i + "6", "item " + i + "7", "item " + i + "8",
  35. "item " + i + "9", "item " + i + "10" }, i);
  36. }
  37. addComponent(table);
  38. HorizontalLayout buttonsLo = new HorizontalLayout();
  39. buttonsLo.setSpacing(false);
  40. addComponent(buttonsLo);
  41. Button setTableWidth100 = new Button("table.setWidth(100%)",
  42. event -> table.setWidth("100%"));
  43. Button setParent500px = new Button("layout.setWidth(500px)",
  44. event -> table.getParent().setWidth("500px"));
  45. Button setParent100 = new Button("layout.setWidth(100%)",
  46. event -> table.getParent().setWidth("100%"));
  47. buttonsLo.addComponents(setTableWidth100, setParent500px, setParent100);
  48. }
  49. }