-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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>
the mvvm file
import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import com.nagarro.model.Request;
import com.nagarro.viewmodel.helper.AdvancedTreeModel;
import com.nagarro.viewmodel.helper.TreeList;
import com.nagarro.dto.Tree;
import com.nagarro.model.TreeNode;
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");
}
}
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
Hi jatinsehgal86
You can bind checkable attribute to the combobox.
<combobox if="${node.checkable}">
Asked: 2013-01-30 09:48:16 +0800
Seen: 60 times
Last updated: Feb 05 '13
Which checkboxes you are talking about?
sjoshi ( 2013-01-30 10:20:57 +0800 )edit