Tooltip in header checkbox grid

I set up the grid as follows: grid.setSelectionMode(Grid.SelectionMode.MULTI); is there a way to add the tooltip on the grid header related to the checkbox?

You mean a tooltip for the Checkbox?

I need to add the tooltip in the header (see image)
image.png

That’s no possible with the Java API

You could do something like this

getElement().executeJs("document.getElementById('selectAllCheckbox').title = 'Hello Select All'");

But this must run after the page has been fully loaded

This is a very hacky solution, because it needs a timeout to make sure that the page is fully loaded

addAttachListener(event -> getElement().executeJs("""
                setTimeout(function() {
                    document.getElementById('selectAllCheckbox').title = 'Hello Select All'
                }, 2000);"""));

Maybe someone else has a better solution

That could be a useful feature actually. You could make a feature request ticket at https://github.com/vaadin/web-components/issues/new?assignees=&labels=&template=feature-request.yml

I tried but it doesn’t work `public Grid buildGrid() {
Grid grid = new Grid<>(Person.class, false);

    grid.setSelectionMode(Grid.SelectionMode.MULTI);
    grid.addColumn(Person::getFirstName).setHeader("First name");
    grid.addColumn(Person::getLastName).setHeader("Last name");
    grid.addColumn(Person::getEmail).setHeader("Email");

    grid.setItems(generatePerson());
    grid.getColumns().get(0).getElement().executeJs("grid.getElementById('selectAllCheckbox').title = 'Hello Select All'");
    return grid;
}`

checkout my code

it’s wrapped in a setTimeout method

otherwise the call is too early

The second solution you provided worked. I would not however that the setTimeout can give errors.

Thank you very much!