Been at it for hours. Probably missing something simple. I am trying to open a folder to force it to fetch the entire branch of the tree. Tree is loaded on demand.
I tried few different options, I created the following recursive method. Then I realized that data is fetched asynchronously so I implemented recursive call using treeGrid.addFolderOpenedHandler(). My problem is that tree.openFolder(node) does not trigger FolderOpenedEvent.
Here is the implementation of the event handler:
Maybe I am just going down the wrong path. Is there a sample somewhere which allows to open all folders within the branch by simply opening the first one. I don't really need to see the folder opened in the UI, but I do need to have the branch fetched. The bottom line is that I need to get TreeNode[] of the entire branch but all Tree methods to getLeaves() and getFolders() only operate on already loaded data thus I am trying to get it all loaded first.
thanks,
Henry
I tried few different options, I created the following recursive method. Then I realized that data is fetched asynchronously so I implemented recursive call using treeGrid.addFolderOpenedHandler(). My problem is that tree.openFolder(node) does not trigger FolderOpenedEvent.
Code:
loadBranch(groupsTreeGrid, droppedRecord); public void loadBranch(TreeGrid treeGrid, TreeNode node){ Tree tree = treeGrid.getData(); //tried treeGrid.getTree() as well tree.openFolder(node); TreeNode[] treeNodes = tree.getOpenList(node); for(TreeNode treeNode : treeNodes){ if(!treeNode.getAttribute("id").equalsIgnoreCase(node.getAttribute("id"))) //ignore self loadBranch(treeGrid, treeNode); } }
Code:
treeGrid.addFolderOpenedHandler(new FolderOpenedHandler() { @Override public void onFolderOpened(FolderOpenedEvent folderOpenedEvent) { Tree tree = treeGrid.getData(); TreeNode[] treeNodes = tree.getOpenList(folderOpenedEvent.getNode()); for(TreeNode treeNode : treeNodes){ if(!treeNode.getAttribute("id").equalsIgnoreCase(folderOpenedEvent.getNode().getAttribute("id"))) tree.openAll(treeNode); } } });
thanks,
Henry
Comment