-
FEATURED COMPONENTS
First time here? Check out the FAQ!
hello,
i tried the example given in http://www.zkoss.org/forum/listComment/10452 and i slightly altered it to add one more header and how can i set values to that using arraylist
<window id="win" title="Hello World!!" border="normal" width="200px" apply="com.test.tets"> <listbox id="listbox" > <listhead> <listheader label="Name"></listheader> <listheader label="Age"></listheader> </listhead> </listbox> <button label="add" onClick="win$composer.add()" /> <button label="remove" onClick="win$composer.remove()" /> </window>
package com.test; import java.util.ArrayList; import java.util.List; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.util.GenericForwardComposer; import org.zkoss.zul.*; public class tets extends GenericForwardComposer { protected Listbox listbox; // autowired private ListModelList list; // the model of the listbox @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); List<String> data = new ArrayList<String>(); data.add("Hello"); data.add("World"); data.add("!"); list = new ListModelList(data, true); // if live is set to true the data list will also be modified listbox.setModel(list); } public void remove() { if(list.size() > 0) list.remove(0); } public void add() { list.add("TEST"); } }
I think you forgot to use listcell. if you have 2 header then should use 2 listcell item.
<listbox fixedLayout="true" id="box" mold="paging" pageSize="31" rows="5" height="500px" model="@{win$composer.AllProducts}" selectedItem="@{win$composer.current}"> <listhead> <listheader width="20px" id="checkbox" /> <listheader width="100px" id="productName" label="Product_Name" sort="auto(name)" /> <listheader id="category" label="Category" width="50px" sort="auto(cat)" /> <listheader id="quantity" label="Quant" width="50px" sort="auto(quant)" /> <listheader id="cDate" label="Date" width="90px" sort="auto(date)" /> </listhead> <listitem self="@{each='event'}" value="@{event}"> <listcell> <checkbox id="cbox" forward="onCheck=onChecked" /> </listcell> <listcell label="@{event.name}" /> <listcell label="@{event.cat}" /> <listcell label="@{event.quant}" /> <listcell label="@{event.date}" /> </listitem> </listbox>
Asked: 2010-12-09 01:13:45 +0800
Seen: 523 times
Last updated: Jan 04 '11