PDA

View Full Version : CheckBoxListView new method setCheckAll



infips00
22 Oct 2009, 11:10 PM
Hi,

I recommend to add this method to the CheckBoxListView to improve the performance of the component when you want to check all the element of the list.


/**
* Selects a all items in the view
*
* @param checked true to check
*/
public void setCheckedAll(boolean checked) {
if (rendered) {
NodeList<Element> nodes = el().select(getCheckBoxSelector());
for (int index = 0; nodes!=null && index < nodes.getLength(); index++) {
Element e = nodes.getItem(index);
if (e != null) {
((InputElement) e.cast()).setChecked(checked);
}
}
} else {
if (checkedPreRender == null) {
checkedPreRender = new ArrayList<M>();
}
if (checked) {
checkedPreRender.addAll(getStore().getModels());
} else {
checkedPreRender.removeAll(getStore().getModels());
}
}
}