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.5KB

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