`

zk 3.6数据绑定

    博客分类:
  • ZK
阅读更多
转载:http://hi.baidu.com/jspring/blog
官网提供了listbox的数据绑定,测试了下相当不错,再试试grid绑定和自动排序。

zul页面
官网提供了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
分享到:
评论
2 楼 yufylovefl 2011-02-23  
请问能不能把com.udooo.window.BookWindow的代码贴出来 谢谢
1 楼 百威 2009-04-17  
后台绑定
public void getItemList()
	{
		String userid = (String) Sessions.getCurrent().getAttribute("user");
		String allname = ((Textbox)getFellow("allname")).getValue();
		Items items = new Items();
		List alist = new ArrayList();
		alist = items.getItemList(userid, allname);
		Listbox box = (Listbox)this.getFellow("box");
		while(box.getItemCount() > 0){
			box.removeItemAt(0);
		}
		for(int i = 0; i < alist.size(); i++){
			ItemsVo vo = (ItemsVo) alist.get(i);			
			Listitem li = new Listitem(); 
		   	li.appendChild(new Listcell(vo.getAllname()));
		   	li.appendChild(new Listcell(vo.getPhone()));
		   	li.appendChild(new Listcell(vo.getEmail()));
		   	box.appendChild(li);
		}
		
	}

相关推荐

Global site tag (gtag.js) - Google Analytics