0

Unable to select tree child when tree is in closed state

asked 2014-08-13 12:29:28 +0800

nirmalmandhata gravatar image nirmalmandhata flag of India
2 3

Requirement: When user selects the tree row, all the available children should also be selected.

Implemeneted: calling select method through OnSelect event and making the child selected Treechildren children = SelectedItem.getTreechildren(); for(Treeitem i:children.getItems()){ i.setSelected(isChecked); } But here the children is null and if we open the tree then it shows the available children and selects it.

Question: Is there any way to select child node when the tree is in closed state?

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2014-08-14 04:51:14 +0800

hawk gravatar image hawk
2335 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2014-08-14 04:51:50 +0800

I made an example to select children of closed treeitem and it works fine under zk 6.5.6

<zk>
<window title="new page title" border="normal">

<tree id="tree1" width="400px" rows="8" multiple="true" checkmark="true" onSelect="selectChildren(event)">
    <treecols sizable="true">
        <treecol label="Name" />
        <treecol label="Description" />
    </treecols>
    <treechildren>
        <treeitem >
            <treerow>
                <treecell label="Item 1" />
                <treecell label="Item 1 description" />
            </treerow>
        </treeitem>
        <treeitem open="false" id="item2">
            <treerow>
                <treecell label="Item 2" />
                <treecell label="Item 2 description" />
            </treerow>
            <treechildren>
                <treeitem >
                    <treerow>
                        <treecell label="Item 2.1" />
                    </treerow>
                    <treechildren >
                        <treeitem>
                            <treerow>
                                <treecell label="Item 2.1.1" />
                            </treerow>
                        </treeitem>
                    </treechildren>
                </treeitem>
                <treeitem>
                    <treerow>
                        <treecell label="Item 2.2" />
                    </treerow>
                    <treechildren>
                        <treeitem>
                            <treerow>
                                <treecell label="Item 2.2.1" />
                            </treerow>
                        </treeitem>
                    </treechildren>
                </treeitem>
            </treechildren>
        </treeitem>
        <treeitem label="Item 3" />
    </treechildren>
</tree>
<button label="select item child" onClick="seletItemChild()"></button>
<zscript>
    <![CDATA[
             import org.zkoss.zul.*;
             public void seletItemChild(){
                 item2.getTreechildren().getItems().iterator().next().setSelected(true);
                 item2.setOpen(true);
             }

             public void selectChildren(Event event){
                 Tree tree = (Tree)event.getTarget();
                 Treeitem selectedItem = tree.getSelectedItem();
                 Treechildren children = selectedItem.getTreechildren(); 
                 for(Treeitem i:children.getItems()){ 
                     i.setSelected(true);
                }
                 selectedItem.setOpen(true);
             }
             ]]>
</zscript>
</window>

</zk>

link publish delete flag offensive edit
Your reply
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
2 followers

RSS

Stats

Asked: 2014-08-13 12:29:28 +0800

Seen: 17 times

Last updated: Aug 14 '14

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