jeudi 7 septembre 2017

How to set that all check-boxes be selected when root check-box is selected(GWT, GXT)?

I am developing an app where I am using com.google.gwt.user.client.ui.Tree; and com.google.gwt.user.client.ui.TreeItem; and com.extjs.gxt.ui.client.widget.form.CheckBox; for creating tree with checkboxes. But I can't set that when root checkbox is selected that all checkboxes from that tree also become selected. This is my code for creating tree with checkboxes:

for (GwtDomain gwtDomain : result) {
                    allCheckBox = new CheckBox();
                    writeCheckBox = new CheckBox();
                    readCheckox = new CheckBox();
                    deleteCheckBox = new CheckBox();
                    treeItem2 = new TreeItem(allCheckBox);

                    read =  new TreeItem(readCheckox);
                    write = new TreeItem(writeCheckBox);
                    delete = new TreeItem(deleteCheckBox);
                    allCheckBox.setBoxLabel(gwtDomain.toString());
                    writeCheckBox.setBoxLabel(GwtAction.write.toString());
                    readCheckox.setBoxLabel(GwtAction.read.toString());
                    deleteCheckBox.setBoxLabel(GwtAction.delete.toString());
                    allCheckBox.setFieldLabel(gwtDomain.toString());
                    readCheckox.setValue(true);
                    allCheckBox.addListener(Events.OnClick, new Listener<BaseEvent>() {

                        @Override
                        public void handleEvent(BaseEvent be) {
                           treeItem2.setSelected(true);
                           if (treeItem2.isSelected()){
                               readCheckox.setValue(true);
                           }
                        }
                    });
                    treeItem2.addItem(read);
                    treeItem2.addItem(write);
                    treeItem2.addItem(delete);

                    t.addItem(treeItem2);


                }

I tried to set that with this listener on allCheckBox(this is root checkbox) but with no success. Does someone have idea how to solve this problem?

Aucun commentaire:

Enregistrer un commentaire