Vaadin: 8.0.5
The DescriptionGenerator for a grid in Vaadin should have a max width and break lines. Otherwise you get an ugly description like this.

The problem seems to be, that default a description is in ContentMode.PREFORMATTED. Add the possibility to set the ContentMode for a descriptiongenerator.
Is there a workaround for allowing HTML content inside a DescriptionGenerator? I would expect a second parameter or something like the method in AbstractComponent:
public void setDescription(String description, ContentMode mode)
I agree that the alternative versions of setDescriptionGenerator methods (on Grid and on Column) would be useful.
Unfortunately, there is no trivial workaround - a proper implementation would require changes in GridConnector.getTooltipInfo() as well as in the communication to communicate the modes for the grid level (rows) and for each column (cells).
The only reasonably quick workaround I can think of would involve a customized version of GridConnector that overrides the method getTooltipInfo(), and has a Connect annotation for a corresponding subclass of Grid.
Would make sense to have that possibility, because I think it's a pretty common scenario to show HTML content inside a tooltip of a grid cell.
Could you point me in the right direction on how to implement that? I already have a subclass of Grid called LGrid und that's how my LGridConnector looks like:
@Connect(de.lobster.vaadin.gui.grid.LGrid.class)
public class LGridConnector extends GridConnector {
@Override
public TooltipInfo getTooltipInfo(Element inElement) {
TooltipInfo tt = super.getTooltipInfo(inElement);
tt.setContentMode(ContentMode.HTML);
return tt;
}
}
That snippet looks almost correct to me, but probably needs to also handle the case where super.getTooltipInfo() returns null.
Doesn't seem to work like that... am I missing anything else in my LGrid class maybe?
Why is nobody else missing that feature? We really need that possibility to display styled tooltips in our grid and the provided workaround doesn’t seem to work… any other ideas?
Would be really helpfull! I miss such a feature!
We're currently upgrading an app to vaadin-8 and missing this feature as we widely used it in vaadin-7
Works like @sirbris and @hesara (suggested additonal null check) suggested. Same fix also works for treegrid.
I miss this as well... Posted my thoughts on #8853 as this seems to be a duplicated of that issue.
Why is this an enhancement? It was already possible before migrating to Vaadin 8
The earlier occurence of this was judged enhancement earlier: https://github.com/vaadin/framework/issues/8853
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;
})
Starting from 8.2.0.alpha3 you have access to Column::setDescriptionGenerator(DescriptionGenerator, ContentMode) which allows you to modify the content mode for the tooltips.
@tsuoanttila Not yet in v7 Grid, right? Pull request #10396 is still waiting for approval.
Most helpful comment
Why is nobody else missing that feature? We really need that possibility to display styled tooltips in our grid and the provided workaround doesn’t seem to work… any other ideas?