0

我有一个设置了 sort="auto" 的 listheader 元素,但是当我单击该列时,该列表不会排序。箭头出现并反向,但列表顺序不会改变。

附加到列表的组件是org.zkoss.zul.A对象,这似乎是排序不起作用的原因。

是否有一种解决方法可以让列表项为 A 对象的 Listbox 工作?

我的祖尔:

<listbox id="myList" checkmark="true" multiple="true">
  <listhead>
    <listheader id='select' label="" width="30px" align="left"/>
    <listheader label="myLabel" width="75px" sort="auto"/>
  </listhead>
</listbox>

时髦的:

Listitem li = new Listitem(value: "myId")
li.appendChild(new Listcell())
Listcell listcell = new Listcell()
Long theId = "12345"
A link = new A(label: theId.toString(), style: "color:blue;")
listcell.appendChild(invoiceLink)
li.appendChild(listcell)
4

2 回答 2

0

我正在使用 MVVM 方法,这就是我对列表框进行排序的方式

<listbox>
     <listhead>
        <listheader label="Hopper" width="60px" sort="auto(hopperCode)" />
        <listheader label="Stop Time" width="80px" sort="auto(startTime)" />
    </listhead>
    <template name="model">
        <listitem>
            <listcell label="@load(each.hopperCode)" />
            <listcell label="@load(each.startTime)" />
        </listitem>
    </template>
</listbox>
于 2017-08-24T00:22:49.567 回答
0

根据文档中的这一段, sort 自动按listcell 的标签排序。您没有使用Listcell.setLabel(),而是将组件附加A到它。由于列表单元的标签都是相同的(即“”),排序不会做任何事情。

尝试设置自定义比较器。为此,我建议使用模型而不是自己创建列表项。

于 2017-08-25T07:27:24.697 回答