Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ColumnWidths.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.data.Item;
  3. import com.vaadin.data.util.IndexedContainer;
  4. import com.vaadin.tests.components.TestBase;
  5. import com.vaadin.ui.Label;
  6. import com.vaadin.ui.Table;
  7. public class ColumnWidths extends TestBase {
  8. @Override
  9. protected String getDescription() {
  10. return "On window resize undefined "
  11. + "columns (by server or user (dragged)) columns "
  12. + "must consume the excess space. Space is divided "
  13. + "by default according to natural widths of columns."
  14. + "In example last column is fixed width. Other columns"
  15. + " should divide excess space relatively to 'natural' width unless user has resized column.";
  16. }
  17. @Override
  18. protected Integer getTicketNumber() {
  19. return 2804;
  20. }
  21. private static final int ROWS = 100;
  22. @Override
  23. public void setup() {
  24. Table table1 = initTable();
  25. addComponent(new Label("Plain table"));
  26. addComponent(table1);
  27. }
  28. private Table initTable() {
  29. Table table = new Table();
  30. table.setWidth("100%");
  31. IndexedContainer idx = new IndexedContainer();
  32. idx.addContainerProperty("firstname", String.class, null);
  33. idx.addContainerProperty("lastname", String.class, null);
  34. Item i = idx.addItem(1);
  35. i.getItemProperty("firstname").setValue("John");
  36. i.getItemProperty("lastname").setValue("Johnson");
  37. i = idx.addItem(2);
  38. i.getItemProperty("firstname").setValue("Jane");
  39. i.getItemProperty("lastname").setValue("Janeine");
  40. for (int index = 3; index < ROWS; index++) {
  41. i = idx.addItem(index);
  42. i.getItemProperty("firstname").setValue("Jane");
  43. i.getItemProperty("lastname").setValue("Janeine");
  44. }
  45. idx.addContainerProperty("150pxfixedCol", String.class, "foobar");
  46. table.setContainerDataSource(idx);
  47. table.setColumnHeader("firstname", "FirstName");
  48. table.setColumnHeader("lastname", "LastName with long header");
  49. table.setColumnWidth("150pxfixedCol", 150);
  50. return table;
  51. }
  52. }