Flow's TreeGrid

Hi Guys ,

Is there any explanation to TreeGrid’s lazy loading feature ? …

i couldnt successfully initialized the items in the first place because of the

            public int getChildCount(HierarchicalQuery<AkademikBirim, Void> query) {
                return akademikBirimService.getChildrenCount(query.getParent());

query.getParent() is null at beginning.

i remember vaadin7’s logic was simple. just add the root items … and then implement something like “additemandexpand” event. and in this event you just need to call getChildren.

But this hasChildren & getChildrenCount methods looks confusing and unnecessary. btw i got the idea why we are implementing haschildren because treegrid put an expand arrow to that item. but why is it calling getchildrencount as well ? … i dunno i made a mistake while debugging. but it was calls those two methods … always… and its reducing loading time very badly. i am fetching my data from remote restful service.

anyways i hope i could explain myself.

best regards.

query.getParent() is null because root nodes don’t have a parent node. So in this case you should return the root node count.

A lazy loading example can be found here:

Documentation regarding getParent():

Maybe that helps.


public List<AkademikBirim> getChildren(AkademikBirim parent) {
        if (parent == null) {
            return findAllRoots(); // all nodes that has no parents.

        return parent.getChildrenAkademikBirim();

So i added “if” part. now its working.

So this is the only way to lazily loading right ? … there is no such feature “additemandexpand” like TreeTable in v7 ?

TreeGrid has an expand listener: treegrid.addExpandListener(…

But I never used it to add items dynamically.

But I never used it to add items dynamically.

unfortunately me too.(i mean i tried but i couldnt) anyways this gonna do just fine.

btw thanks for the reply =)