TreeGrid: get all items


what is the most efficient way to get all items (not just root items or specific children) from the TreeGrid?

This one just returns the root items…

public Stream<T> getAllItems() { return getDataProvider().fetch(new HierarchicalQuery<>(null, null)); } The only way right now would go through getTreeData().getChildren(item) recursively. Is there a better way?


as far as I can tell, that’s the only way you can do it now. I think you’re better off fetching the items outside of the data provider - there’s no guarantee that there is an end to the hierarchy.


Ok, thanks Olli!

for anyone who is interested, this would be my solution at the moment (TreeGrid subcassed):

    public List<T> getAllItems() {
        ArrayList<T> arr = new ArrayList<>();
        addItemsRecursively(null, arr);
        return arr;

    private void addItemsRecursively(T inItem, ArrayList<T> inList) {
        if (inItem != null) {
        for (T item : getTreeData().getChildren(inItem)) {
            addItemsRecursively(item, inList);