-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I noticed that the only way to programmatically (java) uncheck the checkmark on listbox header is to remove all listitems from the listbox:
for (Iterator<component> itemIterator = listbox.getChildren().iterator(); itemIterator.hasNext();) {
Component item = itemIterator.next();
if (!((item instanceof Listhead) || (item instanceof Auxhead) || (item instanceof Listfoot))) {
itemIterator.remove();
}
}
But if the listbox has no listitems, I can't uncheck the checkmark. As a workaround, I add a not visible listitem, so the listbox is never empty. Is there a better way to accomplish this?
if you use 8.0.x and a ListModel
, you should call ((Selectable)listModel).getSelectionControl().setSelectAll(true)
if you use 7.0.x, call ((Selectable)listModel).setSelection(listModel)
Ref:
I think what now all right...
Hi again, using a ListModelList and ListitemRenderer make my listbox to loose multiple property. What am I missing?
this is my zul code:
<listbox id="myListbox"
multiple="true"
checkmark="true"
nonselectableTags="*"
vflex="1"
style="background-color: #AAAAAA;"
>
and in my java composer:
myListbox.setItemRenderer(new ListitemRenderer<Object>() {
@Override
public void render(Listitem listitem, Object data, int index) throws Exception {
MyData availabilityAvailabilityItem = (MyData) data;
// Here I append some cells to the listitem
}
});
ListModelList<MyData> lm = new ListModelList<MyData>(myDataList);
((Selectable<MyData>)lm).getSelectionControl().setSelectAll(true);
myListbox.setModel(lm);
ListitemRenderer overrides listbox definition on .zul source. I solved multiple issue following:
http://tracker.zkoss.org/browse/ZK-957
So my code now is:
ListModelList<MyData> lm = new ListModelList<MyData>(myDataList);
lm.setMultiple(true);
myListbox.setModel(lm);
Using:
((Selectable<availabilityavailability>)lm).getSelectionControl().setSelectAll(true);
does not solve the problem of header checkbox selected when listbox has no items. That is, if I have an empty listbox and I select header checkbox, if then unfortunately refresh the listbox with an empty list, checkmark remains checked.
You can call ListModelList.getSelectionControl().setSelectAll(false);
to uncheck the checkbox in the listheader.
Asked: 2017-08-29 16:02:22 +0800
Seen: 50 times
Last updated: Sep 04 '17