简体   繁体   中英

java gwt celltable with checkbox

I have a Cell Table of which the last column is a checkbox. I would like to add a Check-All-Box as a footer that when clicked selects every checkbox for every row. Somehow it won't work here is what I got so far:

Column<Object, Boolean> select = new Column<Object, Boolean>(new CheckboxCell()) { 
        @Override 
        public Boolean getValue(Object object) { 
            return msm.isSelected(object); 
        } 
    }; 

    select.setFieldUpdater(new FieldUpdater<Object, Boolean>() { 
        public void update(int index, Object object, Boolean value) {
            msm.setSelected(object, value); 
        } 
    }); 

    final Header selectAllHeader = new Header(new CheckboxCell()) { 
        @Override 
        public Boolean getValue(){ 
            return msm.getSelectedSet().size() == getRowCount(); 
        } 
    }; 

    selectAllHeader.setUpdater(new ValueUpdater<Boolean>() { 
        @Override 
        public void update(Boolean value) { 
            for (Object o : getVisibleItems) { 
                msm.setSelected(o, value); 
            }
        }
    }); 
        //works
    addColumn(select, selectAllHeader);
        //does not work
    //addColumn(select, HEADER, selectAllHeader); 

I used a solution proposed here:

http://code.google.com/p/google-web-toolkit/issues/detail?id=7014

It works nicely. You can use it in your footer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM