Update tree grid in Vaadin 11.0.2

I have added the TreeGrid functionality by updating the POM information in Vaadin 11.
I am able to succesfully show the tree grid with the components I am adding.
However as it can be a large tree I would like to obtain childeren of the root when the parent is clicked.

I thought to do it this way:

        // When clicking on an item in the grid...
        treeGrid.addSelectionListener(event -> {
            Notification.show("Clicked: " + event.toString(), 5000, Notification.Position.BOTTOM_CENTER);
            // Prevents deselection...
            if (treeGrid.getSelectedItems().size() > 0) {
                IRODFile selectedItem = treeGrid.getSelectedItems().iterator().next();
                for (File file : selectedItem.getIrodsFile().listFiles()) {
                    Notification.show(file.getAbsolutePath(), 5000, Notification.Position.MIDDLE);
                    IRODSFileSystem irodsFileSystem;
                    try {
                        irodsFileSystem = IRODSFileSystem.instance();
                        IRODSFileFactory irodsFileFactory = irodsFileSystem.getIRODSFileFactory(new BasicAccessControl().getIRODSAccount());
                        IRODSFile collection = irodsFileFactory.instanceIRODSFile(file.getAbsolutePath());
                        IRODFile collectionFile = new IRODFile(file.getName(), collection, selectedItem);
                        treeGrid.getTreeData().addItem(selectedItem, collectionFile);
                    } catch (JargonException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

The notification shows the sub childs but the grid does not “update”.
Is an additional command to refresh the tree grid such that the clickable child will become a collapsoble folder?

Jasper Koehorst:
I have added the TreeGrid functionality by updating the POM information in Vaadin 11.
I am able to succesfully show the tree grid with the components I am adding.
However as it can be a large tree I would like to obtain childeren of the root when the parent is clicked.

I thought to do it this way:

        // When clicking on an item in the grid...
        treeGrid.addSelectionListener(event -> {
            Notification.show("Clicked: " + event.toString(), 5000, Notification.Position.BOTTOM_CENTER);
            // Prevents deselection...
            if (treeGrid.getSelectedItems().size() > 0) {
                IRODFile selectedItem = treeGrid.getSelectedItems().iterator().next();
                for (File file : selectedItem.getIrodsFile().listFiles()) {
                    Notification.show(file.getAbsolutePath(), 5000, Notification.Position.MIDDLE);
                    IRODSFileSystem irodsFileSystem;
                    try {
                        irodsFileSystem = IRODSFileSystem.instance();
                        IRODSFileFactory irodsFileFactory = irodsFileSystem.getIRODSFileFactory(new BasicAccessControl().getIRODSAccount());
                        IRODSFile collection = irodsFileFactory.instanceIRODSFile(file.getAbsolutePath());
                        IRODFile collectionFile = new IRODFile(file.getName(), collection, selectedItem);
                        treeGrid.getTreeData().addItem(selectedItem, collectionFile);
                    } catch (JargonException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

The notification shows the sub childs but the grid does not “update”.
Is an additional command to refresh the tree grid such that the clickable child will become a collapsoble folder?

I’m not sure if vaadin 11 has the TreeGrid java API integration, but I sure know that version 12 does have it and it works well. Use a AbstractBackEndHierarchicalDataProvider impl. It already has mechanisms for loading only one level of nodes, with offset and limit parameters depending on the visible content.