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.

TableColumnAddAndResize.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.VerticalLayout;
  6. import com.vaadin.v7.ui.Table;
  7. public class TableColumnAddAndResize extends AbstractReindeerTestUI {
  8. @Override
  9. protected void setup(VaadinRequest request) {
  10. String people[][] = { { "Galileo", "Liked to go around the Sun" },
  11. { "Monnier", "Liked star charts" },
  12. { "VÀisÀlÀ", "Liked optics" }, { "Oterma", "Liked comets" },
  13. { "Valtaoja", "Likes cosmology and still "
  14. + "lives unlike the others above" }, };
  15. VerticalLayout content = new VerticalLayout();
  16. final Table table = new Table("Awesome Table");
  17. table.setSizeFull();
  18. table.addContainerProperty("Id1", String.class, "TestString");
  19. table.addContainerProperty("Id2", String.class, "TestString2");
  20. for (String[] p : people) {
  21. table.addItem(p);
  22. }
  23. table.setColumnWidth("Id1", 100);
  24. table.setColumnWidth("Id2", 100);
  25. table.setVisibleColumns("Id1");
  26. content.addComponent(table);
  27. Button button = new Button("Add and Resize");
  28. button.addClickListener(event -> {
  29. table.setVisibleColumns("Id1", "Id2");
  30. table.setColumnWidth("Id2", 200);
  31. });
  32. content.addComponent(button);
  33. addComponent(content);
  34. }
  35. }