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.
HTML content in description of grid cells
Hi,
with the old Table class it was possible to render HTML as a tooltip of a cell by setting the description on a label and returning the label as the component for the cell. How to do that in Vaadin 8 with Grid? I tried using setDescriptionGenerator but that is renderer as normal text and not as HTML.
Thanks in advance.
Mihael
Hi Michael,
you need to add HTMLRenderer to your column in grid, for instanc
grid.addColumn(item -> VaadinIcons.DOWNLOAD.getHtml(), new HtmlRenderer()).setId(Columns.DOWNLOAD.dtoName)
and then
grid.getColumn(Columns.DOWNLOAD.dtoName).setDescriptionGenerator(row -> "your html code");
Just having HtmlRenderer as a renderer didn't do the job.
My code:
table.addColumn(mapPresentation -> {
Position position = positions.get(mapPresentation.getPositionId());
Integer employeeId = position.getCurrentStaffingEmployeeId();
if (employeeId == null) {
return "nicht besetzt";
}
else {
Employee employee = getEmployee(employeeId);
return (employee == null) ? StringUtils.EMPTY : employee.getName();
}
}, new HtmlRenderer()).
setCaption("Besetzung").
setWidth(250.0).
setDescriptionGenerator(mapPresentation -> { return buildCellDescription(mapPresentation, positions); });
Still rendered as plain text (and not HTML).
Anything wrong with my code?
Oh sorry, HTMLRenderer is for data in cell.
Your code is OK.
I`ve tried to insert HTML <b></b> tag in setDescriptionGenerator
grid.getColumn(Columns.DOWNLOAD.dtoName).setDescriptionGenerator(row -> "<b>Click</b>");
But without luck.
Any news on that one? I can only set the ContentMode with "setDescription" for the component itself but I don't see the possibility with the DescriptionGenerator or am I missing something?
I would be interested in this as well. Is this feature planned for 8.1?
I would also be very interested in this feature (especially since it was present in Vaadin 7 and our customers got used to it ....)
I have a workaround for this Problem.
Label has the ContentMode setter, so just use ComponentColumn :)
something like this :
insted of
addColumn(ValueProvider::getValue)
.setDescriptionGenerator(item -> "HTML description"); //NO easy way to set ContentMode to HTML
addComponentColumn(item-> {
Label label = new Label(item.getValue());
label.setDescription("HTML description", ContentMode.HTML); //easy :)
return label;
})
Finally its possible to set an HTML description (tested with Vaadin 8.3.3):
gridColumn.setDescriptionGenerator(e -> "<b>some html code</b>", ContentMode.HTML);