Tree Grid With Lazy Loading

Hi All ,

i have project that has a huge node structure from some web service. it tooks realy long to fill all nodes and its leaves…

so i wanted to implement DataProvider but i didnt manage to work …

hierarchicalDataProvider = new AbstractBackEndHierarchicalDataProvider<Birimv4, Long>() {
            protected Stream<Birimv4> fetchChildrenFromBackEnd(HierarchicalQuery<Birimv4, Long> hierarchicalQuery) {
                return getChildDepartments(hierarchicalQuery.getParent()).stream();

            public int getChildCount(HierarchicalQuery<Birimv4, Long> hierarchicalQuery) {
                return 0;

            public boolean hasChildren(Birimv4 birimv4) {
                return false;

i tried as based on the official sample but it loads empty. anyone know how to fill / initialize it with root node / nodes ?

best regards


you need to implement the getChildCount and hasChildren methods to match the information from fetchChildrenFromBackend.


            protected Stream<Birimv4> fetchChildrenFromBackEnd(HierarchicalQuery<Birimv4, Void> hierarchicalQuery) {
                return yoksisSorgu.fetchChildren(hierarchicalQuery.getParent());
public Stream<Birimv4> fetchChildren(Birimv4 parent) {
        if (parent.getBIRIMUZUNADI() == null) { // beacuse of getting root level
            List<Birimv4> newStream = new ArrayList<>();
        } else {
            Holder<List<Birimv4>> altBirimlerv4 = new Holder<>();
            Holder<Result> sonucHolder = new Holder<>();

            portv4.getChildNodes(parent.getBIRIM().getKOD().longValue(), altBirimlerv4, sonucHolder);


Hi Olli , thanks for reply. i already implemented haschild and count methods based on portv4.getchildnodes method. but that affects query time realy bad and also makes no sense. because for the count calculation i already fetch the data. and fetchchildren again fetchs real data.

and my biggest problem is that root of tree always gets empty. i wrote this

        if (parent.getBIRIMUZUNADI() == null) { // beacuse of getting root level

but it seems its not good solution beacuse it gives error some other child nodes.

on short , i have just one method on that service… and it takes an id to load child nodes. any idea for how to pass an id to fetchchild method ?

ps . hierarchicalQuery.getParent() always null on debug. is it ok its null everytime ?

is this the only way to lazily load data for treegrid ? … i remember there was some method to populate data on click event for treetable / something.

edit : i did check it out… it was hierarchical container. and its addItem method made that “lazy load” can add only root items at the beginning to initialize the tree. and then expand listener did the trick.
i realy didnt get the AbstractBackEndHierarchicalDataProvider’s logic.