How Can I create a TreeGrid with tri-state checkboxes

Hi,
How can I create a TreeGrid with tri-state checkboxes in Vaadin 14+?
Any idea are welcome.
Thanks in advance!

Hi,

Where do you want to add a tri-state checkbox?

If you want to add a checkbox in the hierarchy column you can do this:

TreeGrid<DummyFile> grid = new TreeGrid<>();
        //grid.addHierarchyColumn(DummyFile::getFilename).setHeader("File Name");
        grid.addComponentHierarchyColumn(o -> {
            Checkbox checkbox = new Checkbox();
            checkbox.setIndeterminate(true);

            HorizontalLayout horizontalLayout = new HorizontalLayout(checkbox, new Span(o.getFilename()));
            // avoid the open/close node when click on the checkbox
            checkbox.getElement().addEventListener("click", e -> {}).addEventData("event.stopPropagation()");
            return horizontalLayout;
        }).setHeader("File Name");