-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I'm using a custom listitem renderer in order to render a SimpleGroupsModel. I've realized that if I invoke ( ( Listgroup ) item ).setOpen( true ) upon rendering, this listbox loop
for (Listitem item = getItems().size() <= realOfs ? null: getItems().get(realOfs), nxt; j < pgsz && item != null; item = nxt) {
nxt = nextListitem(item); //retrieve first since it might be changed
if (item.isVisible()
&& (open || item instanceof Listgroupfoot || item instanceof Listgroup)) {
renderer.render(item, j + ofs);
++j;
}
if (item instanceof Listgroup)
open = ((Listgroup) item).isOpen();
}
will start messing things up and invoking my renderer's render method with incoherent sets of arguments (a listgroup with the data corresponding the next listitem, for instance). This will visually translate in an equally chaotic listbox.
I don't know if this behaviour is due to some limitation on what can be done within a ListitemRenderer or can be considered rather a bug.
With kind regards
César Varona
It works fine for me, see sample at zkfiddle
code:
<zk>
<zscript><![CDATA[
String[][] datas = new String[][] {
new String[] { //group 1
// Today
"RE: Bandbox Autocomplete Problem",
"RE: It's not possible to navigate a listbox' ite",
"RE: FileUpload"
},
new String[] { //group 2
// Yesterday
"RE: Opening more than one new browser window",
"RE: SelectedItemConverter Question"
},
new String[] { //group 3
"RE: Times_Series Chart help",
"RE: SelectedItemConverter Question"
}
};
GroupsModel model = new SimpleGroupsModel(datas,
new String[]{"Date: Today", "Date: Yesterday", "Date: Last Week"});
//the 2nd argument is a list of group head
ListitemRenderer renderer = new ListitemRenderer () {
public void render(Listitem listitem, Object obj, int index) throws Exception {
listitem.setLabel(obj.toString());
System.out.println(obj.toString());
if (listitem instanceof Listgroup) {
if ("Date: Today".equals(obj.toString())) {
((Listgroup)listitem).setOpen(true);
} else {
((Listgroup)listitem).setOpen(false);
}
}
}
};
]]></zscript>
<listbox model="${model}" itemRenderer="${renderer}">
<listhead sizable="true">
<listheader label="Subject"/>
</listhead>
</listbox>
</zk>
Asked: 2013-02-01 11:28:49 +0800
Seen: 29 times
Last updated: Mar 05 '13
Hi, can u given a sscce (http://sscce.org/) example, then we can help you quickly, thanks
noahhuang ( 2013-02-04 03:42:00 +0800 )edit