onSelect 事件仅适用于组件,我只想为选定的复选框显示/隐藏我的组合框。
这是我的 zul 文件供参考
![<?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>]
问题快照 在图像中,我只想为已选中复选框的组件显示组合框。对于没有复选框或未选中复选框的组件,不应显示任何组合框。谢谢
这是 mvvm 文件
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");
}
}
树数据是通过一些辅助类准备的,但在这里描述并不重要。