Is it Listitem setSelected() Bug?
22 Dec 2011 03:21:11 GMT
30 Dec 2011 02:08:58 GMT
30 Dec 2011 02:08:58 GMT
change to:
I simply switch the order of this two line, the problem has been resolved.
original:
s.setSelected(false); s.setParent(dst);
change to:
s.setParent(dst); s.setSelected(false);
2 Jan 2012 01:17:32 GMT
2 Jan 2012 01:17:32 GMT
Thanks for your testing.
But can you try the second times?
The problem is also exist.
3 Jan 2012 01:05:32 GMT
3 Jan 2012 01:05:32 GMT
I follow your steps and test again, it has no problems.
When I trying other operations, yes, this problem is also exist.
4 Jan 2012 01:15:15 GMT
4 Jan 2012 01:15:15 GMT
I let the Listitem deselect by Listbox, not itself.
Then, it works:
<zscript><![CDATA[
void move(Listbox src, Listbox dst)
{
List list = src.getChildren();
if(list.size() == 1)
Messagebox.show("Select an item first");
else
{
for(int i = 1; i < list.size(); i++)
{
Listitem s = list.get(i);
if(s.isSelected())
{
s.setParent(dst);
// s.setSelected(false);
i--;
}
}
dst.setSelectedIndex(-1);
}
}
]]></zscript>
I thought the Listbox also maintains the selected status and probably not consistent at that moment.
ZK - Open Source Ajax Java Framework
Hi,
I am trying to do the Dev. guide Example, and i write my want function.
When i choose multi-listitem and then click button to swap other Listbox.
( The choose listitem will be nonselected. )
It's can work. But have some bug or my code error in my step.
This problem is i only choose A. to swap, but B. and C. also swap.
My code is here:
<zk> <hbox> <listbox id="src" rows="0" checkmark="true" multiple="true" width="200px"> <listhead> <listheader label="Population"></listheader> <listheader label="Percentage"></listheader> </listhead> <listitem id="a" value="A"> <listcell label="A. Graduate"></listcell> <listcell label="20%"></listcell> </listitem> <listitem id="b" value="B"> <listcell label="B. College"></listcell> <listcell label="23%"></listcell> </listitem> <listitem id="c" value="C"> <listcell label="C. High School"></listcell> <listcell label="40%"></listcell> </listitem> <listitem id="d" value="D"> <listcell label="D. Others"></listcell> <listcell label="17%"></listcell> </listitem> </listbox> <vbox> <button label="=>" onClick="move(src, dst)"></button> <button label="<=" onClick="move(dst, src)"></button> </vbox> <listbox id="dst" checkmark="true" rows="0" multiple="true" width="200px"> <listhead> <listheader label="Population" width="120px"></listheader> <listheader label="Percentage"></listheader> </listhead> <listitem id="e" value="E"> <listcell label="E. Supermen"></listcell> <listcell label="21%"></listcell> </listitem> </listbox> <zscript> <![CDATA[ void move(Listbox src, Listbox dst) { List list = src.getChildren(); if (list.size() == 1) Messagebox.show("Select an item first"); else { for ( int i = 1 ; i < list.size() ; i++ ) { Listitem s = list.get(i); if ( s.isSelected() ) { s.setSelected(false); s.setParent(dst); i--; } } } } ]]> </zscript> </hbox> </zk>also in here:
http://zkfiddle.org/sample/18qu8p1/1-About-Listitem-setSelected-error
My step is :
1. Choose A. to right Listbox
2. Choose B. to right Listbox
3. Choose C. to right Listbox
4. Choose A. B. C. to left Listbox
5. Choose A. to right Listbox
In 5. The A. B. C. also to the right Listbox.