0

How to add a new Listcell into dynamic Listbox loaded by a model

asked 2011-11-15 17:28:13 +0800

lardig82 gravatar image lardig82
84 2

How to change the label of an item in java?
I would like to render the combo, but it didn't refresh it
I have just alse tried in zul file, this is the code:

<listbox mold="select" id="ppbt2" onCreate="self.setSelectedIndex(0)" >
<zk forEach="${dateTime}">
<listitem label="${each}" value="${each}" >

<attribute name="onClick">
<![CDATA[
Listcell c = new Listcell();
c.setLabel("COL");
self.appendChild(c);
self.setVisible(true);
]]>
</attribute>
</listitem>
</zk>
</listbox>

When I select an item of combo in firefox it show this error:
client error: Failed to mount: c.isSizedByContent is not a function

Please help me, Lara

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2011-11-18 03:17:18 +0800

matthewgo gravatar image matthewgo
375

HI Lara,

Try the following code:

<listitem  label="${each}"  value="${each}"  > 
<attribute name="onClick">
self.label="xxxx";
</attribute>
</listitem>	

link publish delete flag offensive edit

answered 2011-11-18 10:25:45 +0800

lardig82 gravatar image lardig82
84 2

Thanks for the help, but I do not have to add an item (a row in the combo), but a cell.
That is, the items I have are made ​​from a single cell,
but I should reload the combo with the same items, but with the addition of a new cell for each item.
The combo contains the hours, I charge it with the times and add next to each time a different value or text or an image.
I hope you can help me ... thanks so much

link publish delete flag offensive edit

answered 2011-11-27 06:17:34 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

Hi Lara,

Listcell not work with "select" mold, another way is use bandbox with default mold,
please refer to the sample below.

ZKFiddle-Link

TestComposer.java
package j1f5qmi9$v1;

import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zk.ui.ext.*;
import org.zkoss.zk.au.*;
import org.zkoss.zk.au.out.*;
import org.zkoss.zul.*;

public class TestComposer extends GenericForwardComposer{

public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);

}

public void onClick$btn(Event e) throws InterruptedException{
Messagebox.show("Hi btn");
}
}


index.zul
<zk>
<zscript>
List dateTime = new ArrayList();
dateTime.add(new Date());
Integer ppbt3Cells = 0;
</zscript>
<bandbox id="bdx">
<bandpopup id="bdpp" width="200px">
<listbox id="ppbt3" onCreate="self.setSelectedIndex(0)" forEach="${dateTime}" sizedByContent="true">
<listitem label="${each}" value="${each}" >
<attribute name="onClick">
<![CDATA[
Listcell c = new Listcell();
c.setLabel("COL");
self.appendChild(c);
ppbt3Cells++;

bdpp.setWidth(200+ppbt3Cells*37+"px");
bdx.invalidate();
bdx.setOpen(true);
]]>
</attribute>
</listitem>
</listbox>
</bandpopup>
</bandbox>
</zk>

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-11-15 17:28:13 +0800

Seen: 385 times

Last updated: Nov 27 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More