zk 3.6数据绑定

官网提供了listbox的数据绑定,测试了下相当不错,再试试grid绑定和自动排序。

zul页面

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<window id="win" use="com.udooo.window.BookWindow" title="ZK Tutorial" width="1024px" border="normal">
    <listbox model="@{win.books}">
        <listhead sizable="true">
            <listheader label="名称" width="100px" sort="auto(name)" />
            <listheader label="作者" width="250px" sort="auto(author)" />
            <listheader label="出版社" width="250px" sort="auto(pub)" />
            <listheader label="价格" width="250px" sort="auto(price)" />
        </listhead>
        <listitem self="@{each=book}">
            <listcell label="@{book.name}" />
            <listcell label="@{book.author}" />
            <listcell label="@{book.pub}" />
            <listcell label="@{book.price}" />
        </listitem>
    </listbox>
    <space/>
    <grid model="@{win.books}" rowRenderer="com.udooo.renderer.BookRenderer">
        <columns menupopup="auto">
            <column label="名称" sort="auto(name)"/>
            <column label="作者"/>
            <column label="出版社"/>
            <column label="价格"/>
        </columns>
    </grid>
</window>

grid要绑定数据关键是要指定Rowrenderer就好了。

参考文章:

http://en.wikibooks.org/wiki/ZK/How-Tos/Data-Binding

原文地址:https://www.cnblogs.com/okuc/p/4149349.html