1

我正在使用数据绑定并尝试在 ZK 中实现可编辑表(列表框)。

<listbox model="@bind(vm.beanList)" selectedItem="@bind(vm.selectedBean)"
         mold="paging" pageSize="5">
    <listhead>
      <!-- ... -->
    </listhead>

    <template name="model">
      <listitem>
        <listcell>
          <!-- ... -->
        </listcell/>

        <listcell>
          <combobox width="100%" inplace="true"
                    model="@load(vm.otherBeanList)"
                    value="@load(each.property) @converter(vm.propertyConverter)"
                    itemRenderer="@load(vm.propertyComboItemRenderer)"
                    onSelect="@command('propertySelected')"
                    onFocus="@command('cellEditorSelected', item=self)"/>
        </listcell>
      </listitem>
    </template>
  </listbox>

表列之一是组合框。用户可以单击它并从下拉列表中更改选定的值。由于所有组合框都使用一个模型......并且模型实现了 Selectable 接口,用户直接更改所有行中每个组合框中的选定值。所以我需要以某种方式为每个组合框提供单独的模型......或者以某种方式克隆模型......或者完全改变方式。

任何建议都会有所帮助和有价值。

谢谢。

4

1 回答 1

0

通过使用 List 作为模型而不是 AbstractListModel 解决了这个问题。ZK 用模型包装集合,并为每个组合框隐式创建新的 ListModelList。所以每个组合框都使用自己的模型,并且有自己的选择值。

于 2012-05-02T05:30:29.377 回答