0

Tree selection problem

asked 2015-06-09 08:24:01 +0800

Marat gravatar image Marat
1

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

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-06-19 10:14:52 +0800

Darksu gravatar image Darksu
1991 1 4

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

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-06-09 08:24:01 +0800

Seen: 24 times

Last updated: Jun 19 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More