TreeGrid FolderOpenedHandler ... how to sync with dataFetch ?

Hi,

I have a TreeGrid connect to RestDataSource.
When a folder been clicked, it will fetch the child node data
and expand the node.

And now I want to do something with the child node when the folder expanded … so I implement the FolderOpenedHandler.

        treeGrid.addFolderOpenedHandler(new FolderOpenedHandler() {
            public void onFolderOpened(FolderOpenedEvent event) {
                TreeNode node = event.getNode();
                TreeNode[] nodes = treeGrid.getData().getChildren(node);
  
                for (int i=0; i<nodes.length; ++i) {
                    // do something ...
                }
            }
        });

My problem is … when the first time the folder been clicked (opened), the data is still fetching from RestDataSource … so
the for loop doesn’t work.

After the RestDataSource been fetched into TreeGrid, the for loop
work perfectly.

My question is … how can I wait for dataFetch() ready in
FolderOpenedHandler ?

Thanks
KC