0
我正在使用ZK框架,我想用给定列表的值填充组合框,但我还想包括“选择一个...“选项,因为组合不需要提交值。如何在ZK组合框中添加“选择一个...”选项
我的看法是这样的:
<row>
<hbox>
Items:
</hbox>
<combobox width="100%" readonly="true" model="@load(vm.itemList)" selectedItem="@bind(vm.object.item)" >
<template name="model">
<comboitem label="@load(each.description)" />
</template>
</combobox>
</row>
在视图模型我检索列表从数据库中创下了一个纪录,我不希望添加一条记录只为这,如果有可能,我还希望避免在列表中添加空项目。
我觉得应该可以做这样的事情:
<combobox width="100%" readonly="true" model="@load(vm.itemList)" selectedItem="@bind(vm.object.item)" >
<template name="model">
<comboitem label="@load(each.description)" />
</template>
<comboitem label="Select One..."/>
</combobox>
但无论这样或那样的工作原理:
<combobox width="100%" readonly="true" model="@load(vm.itemList)" selectedItem="@bind(vm.object.item)" >
<template name="model">
<comboitem label="@load(each.description)" />
<comboitem label="Select One..."/>
</template>
</combobox>
谢谢你的回答!这是我为之努力的解决方案,它解决了这个问题,但我并不十分喜欢它(我没有抱怨你的贡献),它增加了控制更新父对象之前选择的值的逻辑,它是否是这个“假”价值。 –
我会尝试在编辑中建议的解决方案,这非常有趣,谢谢! –