-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I'm using the ZK Tree component, and I'd like that when the page is showed the first time the tree appears expanded.
The problem is that, by default, the tree always appears collapsed.
I've found this link Open treeitem at start , but it just explain how to open an element in the tree and not the whole tree.
I'd like to know if there's any option to expand the whole tree, or if it would be feasible to create a new function expandAll on Tree component.
Thanks,
Rego
You must modified to your needs.
public void onClick$btnMainMenuExpandAll(Event event) throws Exception { if (logger.isDebugEnabled()) { logger.debug("--> " + event.toString()); } doCollapseExpandAll(getMainMenuWindow(), true); } public void onClick$btnMainMenuCollapseAll(Event event) throws Exception { if (logger.isDebugEnabled()) { logger.debug("--> " + event.toString()); } doCollapseExpandAll(getMainMenuWindow(), false); } private void doCollapseExpandAll(Component component, boolean aufklappen) { if (component instanceof Treeitem) { Treeitem treeitem = (Treeitem) component; treeitem.setOpen(aufklappen); } Collection<?> com = component.getChildren(); if (com != null) { for (Iterator<?> iterator = com.iterator(); iterator.hasNext();) { doCollapseExpandAll((Component) iterator.next(), aufklappen); } } }
regards
Stephan
setOpen method of Treeitem works right ;-)
Thank you very much,
Rego
A simpler answer:
void expandTree(Boolean expander){
Collection itm = myTree.getItems();
if (itm != null){
for (item : itm){
if (item instanceof Treeitem) {
Treeitem treeitem = (Treeitem) item;
treeitem.setOpen(expander);
}
}
}
}
Hi, I want to expand the items of a tree as well, but I got a ConcurrentModificationException.
My problem is that I am trying to fetch a selected item with "getSelectedItems()" and it is on the "3rd level" of the tree, the "very last node".
As by default the tree is only opened up to the second level (the main nodes and their children), it returns no selected items.
I tried to render the tree completely and open all the nodes when it is loaded. I also tried the solutions posted here, with no success.
I have also tried with getTreechildren() and renderItemByPathApi(path), which both don't raise any exception but don't give the desired results.
Thanks in advance.
Hi terrytornado
Thank you very much for expand all and collapse all. It works well
:-)
Asked: 2009-08-21 07:48:28 +0800
Seen: 1,844 times
Last updated: Oct 02 '12