-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a tree, with multiple selection.
Tree has 3 folders with 10 objects in each folder.
Folders and objects within folders are all selected.
I made a onSelect command which made objects in folder selected or unselected when
folder have been selected or unselected.
@Command public void treeSelect(@ContextParam(ContextType.TRIGGER_EVENT)SelectEvent event) { Clients.log("selection count before select " + treeModel.getSelectionCount()); Treeitem item = (Treeitem)event.getReference(); DefaultTreeNode<treeobject> treenode = item.getValue(); TreeObject node = treenode.getData(); if(node.getType() == 1){ // folder if(item.isLoaded()) { for (Treeitem child : item.getTreechildren().getItems()) { child.setSelected(item.isSelected()); if (item.isSelected()) { treeModel.addToSelection((DefaultTreeNode<treeobject>)child.getValue()); } else { treeModel.removeFromSelection((DefaultTreeNode<treeobject>)child.getValue()); } TreeNode<treeobject> childNode = child.getValue(); childNode.getData().setSelected(item.isSelected()); } }else{ for(TreeNode<treeobject> child: treenode.getChildren()){ if(item.isSelected()){ treeModel.addToSelection(child); }else{ treeModel.removeFromSelection(child); } child.getData().setSelected(item.isSelected()); } } node.setSelected(node.isSelected()); } Clients.log("selection count after select " + treeModel.getSelectionCount()); }
The problem:
When i unselect first folder it shows correct info that 22 elements still in selection (2 folders and 20 objects in folders).
And then when i unselect second folder it shows that only 1 element in selection - only third folder element. Selection of objects in third folder disappeared!
example in zkfiddle: /sample/353rb3u/3-ZK-Tree-selection-problem#source-2
Hello Marat,
I have tested your code, and unfortunately have found some additional issues.
Thus I think the best thing to do is to describe your business scenario so that we can find the best solution for it.
Best Regards,
Darksu
Asked: 2015-06-09 08:24:01 +0800
Seen: 25 times
Last updated: Jun 19 '15
Large Tree with dynamic columns
Tree width lost after changing col width on maximized panel
MVVM tree example to show add/insert/delete/move/drag?
Error writing 'checked' on type org.zkoss.zul.Checkbox [closed]
Problem with changing MVVM tree model
zk framework: how to load zul pages from WEB-INF under directory zul