-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I have a tree with many treeitems. I now expand some nodes and make a multiple selection on some nodes which have children using the shift key. Unfortunately, the children are selected as well. This is not the correct behavior as the children are not visible at all. In effect, the semantics of the following operation is broken. For instance
* select 20 nodes using shift
* the tree selection contains 60 nodes
* press copy (copying 60 instead of the intended 20 nodes)
* paste ("flattens" the hierarchy, resp. duplicates erroneously selected children)
Can this behavior be turned off somehow?
Cheers,
David
Hi,
I now traverse the selection and remove those nodes that may be selected erroneously.
private Set<Treeitem> removeInvisibleNodes(Set<Treeitem> selection) { Set<Treeitem> visibleSelection = new HashSet<Treeitem>(); for ( Treeitem item : selection ) { boolean visible = true; Treeitem current = item.getParentItem(); while ( current != null && visible ) { visible = current.isOpen(); current = current.getParentItem(); } if ( visible ) { visibleSelection.add(item); } } return java.util.Collections.unmodifiableSet(visibleSelection); }
Help would be highly appreciated.
Thanks beforehand,
David
Hi David,
So you need to use shift select and do not select invisible children nodes, is it correct?
Hi David,
There is no configuration for tree selection, but you can try to override the client function of the Tree, please refer to the following sample
tree.setWidgetOverride("getBodyWidgetIterator", "function (opts) {opts = opts || {};opts.skipHidden=true;return new zul.sel.TreeItemIter(this, opts);}");
Asked: 2012-09-25 07:49:32 +0800
Seen: 93 times
Last updated: Oct 12 '12