0

Is this an issue with checkbox or some tweak!

asked 2012-11-28 07:40:08 +0800

buch11 gravatar image buch11
45 3

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 :-)

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-11-29 05:44:55 +0800

buch11 gravatar image buch11
45 3

updated 2012-11-29 05:46:15 +0800

PS : Fiddle link : http://zkfiddle.org/sample/1vilk89/13-listbox-and-checkboxes


ZKFiddle-Link

TestComposer.java
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());
}
}

}


index.zul
<?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>

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: 2012-11-28 07:40:08 +0800

Seen: 80 times

Last updated: Nov 29 '12

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