Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Table: Line break in header, items with different types
Hi guys,
i try to rebuild my old site with vaadin. But i have 3 problems with the table.
1. Is it possible to use a line break in the header?
I use something like that
String[] columnHeaders = {"foo/nbar"};
setColumnHeaderMode(COLUMN_HEADER_MODE_EXPLICIT);
setColumnHeaders(columnHeaders);
2. Is it possible to prevent resizing of the table columns?
3.This is the biggest problem for me. Can i add items with different types to a table?
I want to add a summary row to my table. In the "normal" rows i have icons (Embedded). And now i want to add a summary that counts all the same icons of the column and show the result as string/integer. But i don't know how. I created a item with Integer/String, i add an embedded and set only the caption, but nothing works.
addContainerProperty(0, String.class, null);
addContainerProperty(1, Embedded.class, null);
addItem(new Object[] {"test", new Embedded(..)}, 1);
addItem(new Object[] {"test", 3}, 2);
Thanks
Caspar
Hi Christian, and welcome to the forum!
Christian c: 1. Is it possible to use a line break in the header?
Sorry, not out of the box. This will require at least theme modifications and most likely client-side GWT modifications as well.
Christian c: 2. Is it possible to prevent resizing of the table columns?
I don't think it is, currently. Why would you need that, what's the use case?
Christian c: 3.This is the biggest problem for me. Can i add items with different types to a table?
Generic component captions aren't rendered by the Table component, they are usually only rendered when the component is placed inside some layout.
So a workaround could be that you specify the column type as a layout (CssLayout would be best), and place the Embedded icons inside that. Same for the "summary" row, just add a label inside the layout that indicates the number of icons.
I must say, I'm no guru on the data model of Vaadin, so if someone else has a better suggestion, please share.
Hi Jouni,
thanks for the quick response.
I will try the hint with the layout cells. Maybe this can fix my other problems, too. I think about hiding the default header and adding my own header row to the table.
Do you know a method to add a style to one row only?
Ps. The idea for disabling resizing was only a personal thing. I see no use for resizing (in my case). The content width is nearly stable. And the cell content is smaller when the header caption. So there is no use to enlarge the columns and a smaller column would only hide the header caption. So i thought the best thing is to cut off this functionality.
Christian c:
2. Is it possible to prevent resizing of the table columns?
Haven't tested, but the following CSS should do the trick:
.v-table .v-table-resizer {
display: none;
}