Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:14:04+00:00 2026-06-18T04:14:04+00:00

The onSelect event is present for the component only and I want to show/hide

  • 0

The onSelect event is present for the component only and I want to show/hide my comboboxes for selected checkboxes only.

Here is my zul file for reference

![<?page title="MVVM Tree POC"?>
<zk>
    <borderlayout height="800px">
        <west size="25%"></west>
        <center>
            <window apply="org.zkoss.bind.BindComposer"
                viewModel="@id('vm') @init('com.nagarro.viewmodel.TreeViewModel')"
                title="Dynamic Tree" border="normal">
                <tree checkmark="true" model="@bind(vm.treeModel)"
                    onSelect="@command('select')">
                    <treecols>
                        <treecol label="Name" align="center" />
                        <treecol label="Value" align="center" />
                        <treecol label="IP" align="center" />
                    </treecols>
                    <template name="model" var="node" status="s">
                        <treeitem checkable="@load(node.checkable)">
                            <treerow style="text-align:center;">
                                <treecell
                                    label="@bind(node.data.firstName)" style="text-align:left;">

                                </treecell>
                                <treecell style="text-align:center;">
                                    <combobox>
                                        <comboitem label="Fixed" />
                                        <comboitem label="System" />
                                        <comboitem label="Parameter" />
                                    </combobox>
                                </treecell>
                                <treecell style="text-align:center;">
                                    <combobox>
                                        <comboitem label="IP" />
                                    </combobox>
                                </treecell>
                            </treerow>

                        </treeitem>
                    </template>
                </tree>

            </window>
        </center>
    </borderlayout>
</zk>]

snapshot of the issue
In the image I want to show the combo boxes only for the components which have checked checkboxes. There should not be any combobox shown for component without checkbox or unchecked checkbox. Thanks

Here is the mvvm file

public class TreeViewModel {


    private Request request;
    private AdvancedTreeModel treeModel;

    /**
     * @return the treeModel
     */
    public AdvancedTreeModel getTreeModel() {
        if(treeModel == null){
            TreeNode<Tree> treeNode = new TreeList(request).getRoot();
            treeModel = new AdvancedTreeModel(treeNode);
            treeModel.setMultiple(true);
        }
        return treeModel;
    }

    /**
     * @param treeModel the TreeModel to set
     */
    public void setTreeModel(AdvancedTreeModel treeModel) {
        this.treeModel = treeModel;
    }
    @Init
    public void init(){
        try {
            File file = new File("C:\\Users\\jatin1937\\Desktop\\XML files\\Request.xml");
            JAXBContext jaxbContext = JAXBContext.newInstance(Request.class);
            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            request = (Request) jaxbUnmarshaller.unmarshal(file);
        }catch (JAXBException e) {
            e.printStackTrace();
        }
    }

    /**
     * @return the request
     */
    public Request getRequest() {
        return request;
    }

    /**
     * @param request the request to set
     */
    public void setRequest(Request request) {
        this.request = request;
    }
    @Command
    public void select(){
        System.out.println("onSelect method entered");
    }
}

Tree data is prepared through some helper classes but thats not important to describe here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:14:06+00:00Added an answer on June 18, 2026 at 4:14 am

    I also tried it and found a way out. Now, instead of using onSelect event on tree component I am using onClick event on treeRow component. I kept a field isChecked with my class which is referred by node.data in the zul file. According to the value of that boolean isChecked I show/hide the combobox.

    Below is the zul file for reference

    <?page title="MVVM Tree POC"?>
    <zk>
        <borderlayout height="800px">
            <west size="25%"></west>
            <center>
                <window apply="org.zkoss.bind.BindComposer"
                    viewModel="@id('vm') @init('com.nagarro.viewmodel.TreeViewModel')"
                    title="Dynamic Tree" border="normal">
                    <tree checkmark="true" model="@bind(vm.treeModel)">
                        <template name="model" var="node" status="s">
                            <treeitem
                                checkable="@load(node.data.isCheckable)" open="true">
                                <treerow style="text-align:center;"
                                    onClick="@command('select', treeNode = node.data)">
                                    <treecell
                                        label="@bind(node.data.firstName)" style="text-align:left;">
                                    </treecell>
                                    <treecell style="text-align:center;"
                                        if="${node.data.isChecked == true}">
                                        <combobox>
                                            <comboitem label="Fixed" />
                                            <comboitem label="System" />
                                            <comboitem label="Parameter" />
                                        </combobox>
                                    </treecell>
                                    <treecell style="text-align:center;"
                                        if="${node.data.isChecked == true}">
                                        <combobox>
                                            <comboitem label="Fixed" />
                                            <comboitem label="System" />
                                            <comboitem label="Parameter" />
                                        </combobox>
                                    </treecell>
                                </treerow>
                            </treeitem>
                        </template>
                    </tree>
    
                </window>
            </center>
        </borderlayout>
    </zk>
    

    Here is the select method in ViewModel for reference

    @NotifyChange("treeModel")
    @Command
    public void select(@BindingParam("treeNode") final Tree tree){
        if(tree.getIsCheckable()){
            if(tree.getIsChecked() == true){
                tree.setIsChecked(false);
            }else{
                tree.setIsChecked(true);
            }
        }
    
    }
    

    Please note that Tree is a custom class through which I prepare tree
    data. isCheckable is also a boolean field in the Tree class. If
    true then checkbox will appear in a treeRow else not.
    isChecked is another Boolean field in Tree class. If true then
    corresponding checkbox is checked else not

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

want to get dateText from datepicker out of onSelect event, in some other function:
How can I trigger onSelect event when I select a selected date on jQuery
I'm interested in using fcbkcomplete , which has: onselect – fire event on item
When user clicks on select box , I want to hide the options menu
Can I setDate of another text element when the onSelect event fires on the
i have code on the onSelect event of the jquery ui datepicker and i
this is closely related to this post: Is there an onSelect event or equivalent
I am using a html input text and i want to disable the onselect()
I am trying to handle the same onSelect event on a jquery datePicker object
On the execution of onclick or onselect event which have more precedence. Is it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.