-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all ,
I am using a listbox, where the first column is a (checkbox+combobox) combination and the second column is the simple single checkbox.
The issue here is that the check box that comes with the listbox's checkmark="true" property, looks a bit different from the checkbox which is added using <checkbox> tag. How to make both the checkboxes exactly the same?
PS: Firebug suggests that the chkbox(the one added with checkmark=true) is just an image, and implements different css class(I am not very sure about this.)
Thanks in advance...
Happy Coding :-)
PS : Fiddle link : http://zkfiddle.org/sample/1vilk89/13-listbox-and-checkboxes
package j1vilk89$v13;
import java.util.*;
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{
private List<Product> clinicalSites;
private List<Checkbox> selectedCheckboxs;
private Label msg;
private Grid mgrid;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
selectedCheckboxs = new ArrayList<Checkbox>();
clinicalSites = new ArrayList<Product>();
int num = 10;
for (int i = 0; i < num; i++) {
clinicalSites.add(new Product("item" + i));
}
}
public void onModifySelectedList(ForwardEvent event){
Checkbox checkbox = (Checkbox) event.getOrigin().getTarget();
if (checkbox.isChecked())
selectedCheckboxs.add(checkbox);
else selectedCheckboxs.remove(checkbox);
}
public void onClick$updateBtn() {
StringBuilder sb = new StringBuilder();
for (Checkbox checkbox : selectedCheckboxs) {
sb.append(checkbox.getLabel());
sb.append(", ");
}
if (selectedCheckboxs.size() > 0){
int length = sb.length();
sb.replace(length - 2, length, "");
}
msg.setValue(sb.toString());
}
public List<Product> getAllClinicalSites(){
return clinicalSites;
}public class Product{
private String _name;public Product(String name) {
super();
this._name = name;
}public void setName(String name) {
this._name = name;
}
public String getName() {
return _name;
}
}
public void onCheck$selectedAllCheckBox(CheckEvent e){
List components = mgrid.getRows().getChildren();
for(Object obj:components){
Row comp = (Row) obj;
Checkbox ck = (Checkbox) comp.getChildren().get(0);
ck.setChecked(e.isChecked());
}
}}
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<zk>
<window id="win" apply="j1vilk89$v13.TestComposer">
<listbox mold="paging" pageSize="10" checkmark="true" multiple="true">
<listhead>
<listheader label=""></listheader>
<listheader label=""></listheader>
</listhead>
<listitem>
<listcell>
<textbox mold="rounded"></textbox>
</listcell>
<listcell>
<checkbox></checkbox>
</listcell>
</listitem>
</listbox>
<button id="updateBtn" label="Update" />
<label id="msg"/>
</window>
</zk>
Asked: 2012-11-28 07:40:08 +0800
Seen: 80 times
Last updated: Nov 29 '12