Search code examples
javavaadinvaadin7

How to create a complex header in vaadin 7?


I was using setColumnHeader(Object, String) to set a simple string as a column header. I want to create a complex header. I would like to know if there is any way to build a similar table as shown in the below figure in Vaadin 7. https://i.sstatic.net/u5dIw.gif


Solution

  • Now it is possible using Grid:

    enter image description here

    // Group headers by joining the cells
    HeaderRow groupingHeader = grid.prependHeaderRow();
    HeaderCell namesCell = groupingHeader.join(
        groupingHeader.getCell("firstname"),
        groupingHeader.getCell("lastname"));
    HeaderCell yearsCell = groupingHeader.join(
        groupingHeader.getCell("born"),
        groupingHeader.getCell("died"),
        groupingHeader.getCell("lived"));
    

    This example is taken from Vaadin Book. Just to show that new Vaadin 7.5 (and above) can build table with complex header (joined columns). Another good resource is in Vaadin Wiki.

    As you notice such grouping is also possible for footer row.