-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am having issue with Listbox selecting rows after upgrading zk lib from 5.0.5 to 5.0.10.
When I select multiple items in Listbox by holding the shift key getSelectedItems() method return 0 rows.
It’s returning selected rows if I use ctrl + click. In version 5.0.5 it’s selecting rows without any problems by
holding shift or ctrl
Use case.
1. Selecting row one.
2. Scrolling down to row 30.
3. Holding shift + click on row 30
4. All rows is selected
5. getSelectedItems().size() return 0
Here is sample of my code which working fine in 5.0.5
public void onSelect$lbProductGroup(ForwardEvent event)throws Exception{
Listbox listbox = (Listbox) event.getOrigin().getTarget();
Set<Listitem> listitems = (Set<Listitem>)listbox.getSelectedItems();
System.out.println("list size = " + listitems.size());
for (Listitem listitem : listitems) {
System.out.println("value = " + listitem.getValue().toString());
System.out.println("description = " + listitem.getLabel());
}
}
Hi
could you provide a example. I tried my case, it doesn't show this issue.
<zk> <zscript><![CDATA[ java.util.List model = new ArrayList(); for(int i=0;i<100;i++){ model.add("Item "+i); } public void onSelect(){ Set listitems = list.getSelectedItems(); System.out.println("list size = " + listitems.size()); for (Object listitem : listitems) { System.out.println("value = " + listitem.getValue()); } } ]]></zscript> <listbox id="list" width="200px" rows="10" onSelect="onSelect()" multiple="true"> <listhead> <listheader label="Load on Demend" sort="auto"/> </listhead> <listitem forEach="${model}" label="${each}" value="${each}"></listitem> </listbox> </zk>
by the way, if you use model , you should get selection from model. not from listbox.getSelectedItem.
I have the same problem. When I specify the Library Property "org.zkoss.zul.listbox.rod" in the zk.xml to "true", it works.
<library-property> <name>org.zkoss.zul.listbox.rod</name> <value>true</value> </library-property>
you should use model to get the selection, not from listbox.getItems when use model,
if you use CE or EE version and enable ROD. listbox only maintain a sub-set of listitems , that is why you will get 0 when scroll down to the bottom.
Asked: 2012-01-20 15:17:13 +0800
Seen: 198 times
Last updated: Feb 16 '12