Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a Grid cell tooltip in Vaadin Flow

With Vaadin 8 you could set a tooltip for a Grid cell. This feature is not available in Vaadin Flow (currently using v 11.0.0). Is there an alternative?

like image 750
rmuller Avatar asked Sep 15 '18 12:09

rmuller


1 Answers

There is no built-in feature yet. The easiest way is probably to set "title" attribute of the element. One example is to use TemplateRenderer, and there is example of that here

https://vaadin.com/components/vaadin-grid/java-examples/using-templates

Copying the relevant part of the code from the example above

grid.addColumn(TemplateRenderer.<Person> of(
        "<div title='[[item.name]]'>[[item.name]]<br><small>[[item.yearsOld]]</small></div>")
        .withProperty("name", Person::getName).withProperty("yearsOld",
                person -> person.getAge() > 1
                        ? person.getAge() + " years old"
                        : person.getAge() + " year old"))
        .setHeader("Person");
like image 167
Tatu Lund Avatar answered Nov 15 '22 22:11

Tatu Lund