-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725129
By: michaelkmb
According to release note of 1.2.0, the alignment of header and body of grid, listbox and tree are improved to handle all known extremely cases. However, i found my listbox not rendered correctly if itemrenderer is usef. I'm not sure it is due to my coding error or Zk's issue. Please advise.
Try following page and see the different.
Michael
<window>
<zscript>
String[] data = {"1","2","3"};
dataModel = new SimpleListModel(data);
public class dataRenderer implements ListitemRenderer {
public void render(Listitem item, Object data) throws Exception {
for (int j=0;j@lt6;j++) {
cell = new Listcell("col-"+j);
cell.setParent(item);
}
}
}
daRender = new dataRenderer();
</zscript>
<label value="listbox with itemRenderer" /> <listbox id="lb2" model="${dataModel}" itemRenderer="${daRender}" >
<listhead id="lh2">
<listheader label="col1" width="100px" />
<listheader label="col2" width="100px" />
<listheader label="col3" width="100px" />
<listheader label="col4" width="100px" />
<listheader label="col5" width="100px" />
<listheader label="col6" width="100px" />
</listhead>
</listbox>
<label value="general listbox" />
<listbox id="lb1" >
<listhead id="lh1">
<listheader label="col1" width="100px" />
<listheader label="col2" width="100px" />
<listheader label="col3" width="100px" />
<listheader label="col4" width="100px" />
<listheader label="col5" width="100px" />
<listheader label="col6" width="100px" />
</listhead>
</listbox>
<zscript>
for (int i=0;i@lt3;i++) {
item = new Listitem();
for (int j=0;j@lt6;j++) {
cell = new Listcell("col-"+j);
cell.setParent(item);
}
item.setParent(lb1);
}
</zscript>
</window>
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725165
By: michaelkmb
It seems that to make the listbox (with itemRenderer) align properly, following should be added:
1. an extra <listheader> need to be added (with width say "5px"). (since an extra field is generated in the listbox body if model is used)
2. set the width of listbox.
Following is a modified version.
<window>
<zscript>
String[] data = {"1","2","3"};
dataModel = new SimpleListModel(data);
public class dataRenderer implements ListitemRenderer {
public void render(Listitem item, Object data) throws Exception {
for (int j=0;j@lt6;j++) {
cell = new Listcell("col-"+j);
cell.setParent(item);
}
}
}
daRender = new dataRenderer();
</zscript>
<label value="listbox with itemRenderer" /> <listbox id="lb2" model="${dataModel}" itemRenderer="${daRender}" >
<listhead id="lh2">
<listheader label="" width="5px"/>
<listheader label="col1" width="100px" />
<listheader label="col2" width="100px"/>
<listheader label="col3" width="100px"/>
<listheader label="col4" width="100px"/>
<listheader label="col5" width="100px"/>
<listheader label="col6" width="100px" />
</listhead>
</listbox>
<label value="listbox with dynamic data" /> <listbox id="lb1" width="650px" >
<listhead>
<listheader label="col1" width="100px"/>
<listheader label="col2" width="100px"/>
<listheader label="col3" width="100px"/>
<listheader label="col4" width="100px"/>
<listheader label="col5" width="100px"/>
<listheader label="col6" width="100px"/>
</listhead>
</listbox>
<zscript>
for (int i=0;i@lt3;i++) {
item = new Listitem();
for (int j=0;j@lt6;j++) {
cell = new Listcell("col-"+j);
cell.setParent(item);
}
item.setParent(lb1);
}
</zscript>
</window>
Michael
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725169
By: nobody
You need column 7 for your list header since you've got 7 columns rendering.
The Listitem itself come with one cell to begin with.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725196
By: nobody
maybe it should be implemented in ZK such that an empty header automatically shows (or flagged to show through attributes) when there are more columns in rows than headers.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725262
By: michaelkmb
And extra column is added only for live-data listbox. (i.e. "model" attribute
specified)
Michael
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725310
By: henrichen
The reason is the number of Listheader is not consistent with the number of Listcell. And why is that? In ZK's Java API doc, about the method render() of
ListitemRenderer:
http://zk1.sourceforge.net/javadoc/1.2.0/zul/com/potix/zul/html/ListitemRenderer
.html
"Parameters:
item - the listitem to render the result. Note: when this method is called, the listitem has exactly one Listcell (with an empty label). If you want to render to multiple column, you have to create the second and following Listcell."
Your render() code append 6 kids onto the Listitem and make it a 7 kids parent while you prepare only 6 Listheaders and that cause the alignment issue.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725312
By: henrichen
This code should work ok.
<window>
<zscript>
String[] data = {"1","2","3"};
dataModel = new SimpleListModel(data);
public class dataRenderer implements ListitemRenderer {
public void render(Listitem item, Object data) throws Exception {
Iterator it = item.getChildren().iterator(); int j=0; if (it.hasNext()) { Listcell cell = it.next(); cell.setLabel("col-0"); j=1; //j start from 1 }
for (;j@lt6;j++) {
cell = new Listcell("col-"+j);
cell.setParent(item);
}
}
}
daRender = new dataRenderer();
</zscript>
<label value="listbox with itemRenderer" /> <listbox id="lb2" model="${dataModel}" itemRenderer="${daRender}" >
<listhead id="lh2">
<listheader label="col1" width="100px" />
<listheader label="col2" width="100px" />
<listheader label="col3" width="100px" />
<listheader label="col4" width="100px" />
<listheader label="col5" width="100px" />
<listheader label="col6" width="100px" />
</listhead>
</listbox>
<label value="general listbox" />
<listbox id="lb1" >
<listhead id="lh1">
<listheader label="col1" width="100px" />
<listheader label="col2" width="100px" />
<listheader label="col3" width="100px" />
<listheader label="col4" width="100px" />
<listheader label="col5" width="100px" />
<listheader label="col6" width="100px" />
</listhead>
</listbox>
<zscript>
for (int i=0;i@lt3;i++) {
item = new Listitem();
for (int j=0;j@lt6;j++) {
cell = new Listcell("col-"+j);
cell.setParent(item);
}
item.setParent(lb1);
}
</zscript>
</window>
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725318
By: henrichen
The original spec. is not elegant that carry an extra Listcell in Listitem when
render() method of ListitemRenderer is called. I will file a Feature-Request to change it to carry no extra Listcell.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725322
By: henrichen
It is a not good idea to let ZK automatically generate extra Listheader for extra Listcell. It is easy to confuse and suprise the developer.
/henri
Asked: 2006-05-12 01:09:51 +0800
Seen: 1,092 times
Last updated: May 12 '06