0

How to control selectAll() feature in a Listbox with multiple=true and checkmark=true

asked 2017-08-29 16:02:22 +0800

sboscolo gravatar image sboscolo
66 1

updated 2017-08-29 16:12:34 +0800

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?

delete flag offensive retag edit

6 Answers

Sort by ยป oldest newest most voted
0

answered 2017-08-30 06:25:29 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2017-08-30 06:32:08 +0800

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:

link publish delete flag offensive edit
0

answered 2017-08-30 07:25:15 +0800

ellaharris873 gravatar image ellaharris873
1

I think what now all right...

link publish delete flag offensive edit
0

answered 2017-08-30 10:40:10 +0800

sboscolo gravatar image sboscolo
66 1

Thank you all! I will try and I will send you a feedback as soon as possible. Regards.

link publish delete flag offensive edit
0

answered 2017-08-30 16:36:13 +0800

sboscolo gravatar image sboscolo
66 1

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);
link publish delete flag offensive edit
0

answered 2017-08-31 15:55:59 +0800

sboscolo gravatar image sboscolo
66 1

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.

link publish delete flag offensive edit
0

answered 2017-09-04 09:37:12 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

You can call ListModelList.getSelectionControl().setSelectAll(false); to uncheck the checkbox in the listheader.

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2017-08-29 16:02:22 +0800

Seen: 50 times

Last updated: Sep 04 '17

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