-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Listcell cell = new Listcell();
Radiogroup rbtng = new Radiogroup();
Radio rbtn = new Radio();
rbtn.setLabel("Yes");
rbtn.setValue("Y");
rbtn.setRadiogroup(rbtng);
Radio rbtn1 = new Radio();
This code not working how to fix this?
rbtn1.setId("no" + generateDynamicId());
rbtn1.setLabel("No");
rbtn1.setValue("N");
rbtn1.setChecked(true);
rbtn1.setRadiogroup(rbtng);
//
cell.appendChild(rbtng);
cell.appendChild(rbtn);
cell.appendChild(rbtn1);
row.appendChild(cell);
//rbtn1.setChecked(true);
Do this
rbtn1.setParent (rbtng);
Rather than
rbtn1.setRadiogroup(rbtng);
You can either set the parent to radiogroup directly or or set selected radio item after components are attached to the view, then radiogroup can control the exclusive selection.
<zk>
<window border="normal" title="hello" onCreate="build1(self)">
</window>
<zscript><![CDATA[
public void build1(Window window) {
Radiogroup rbtng = new Radiogroup();
Radio btnY = new Radio();
btnY.setLabel("Yes");
btnY.setValue("Y");
btnY.setRadiogroup(rbtng);
Radio btnN = new Radio();
btnN.setLabel("No");
btnN.setValue("N");
btnN.setRadiogroup(rbtng);
window.appendChild(rbtng);
window.appendChild(btnY);
window.appendChild(btnN);
rbtng.setSelectedItem(btnN);
}
]]></zscript>
<window border="normal" title="hello" onCreate="build2(self)">
</window>
<zscript><![CDATA[
public void build2(Window window) {
Radiogroup rbtng = new Radiogroup();
Radio btnY = new Radio();
btnY.setLabel("Yes");
btnY.setValue("Y");
btnY.setRadiogroup(rbtng);
Radio btnN = new Radio();
btnN.setLabel("No");
btnN.setValue("N");
btnN.setRadiogroup(rbtng);
btnN.setChecked(true);
rbtng.appendChild(btnY);
rbtng.appendChild(btnN);
window.appendChild(rbtng);
}
]]></zscript>
</zk>
Asked: 2012-12-03 11:45:09 +0800
Seen: 135 times
Last updated: Jan 22 '13