Keyur Ardeshana
Keyur Ardeshana

Reputation: 204

How to deselect the checkbox after click on it in gwt grid having single selction model

I am using GWT Data grid with single selection model and now i want to deselect the check box cell after click on it on some specific condition.

I have override onBrowserEvent of CheckboxCell and added below line to deselect it.

selectionModel.setSelected(object, false);

but i am not able to deselect it.

Upvotes: 0

Views: 813

Answers (1)

j.s
j.s

Reputation: 236

selectionModel.setSelected(object, false); only deselects the currently selected row. Add a FieldUpdater to the Column containing the CheckboxCell, in which you reset the value of the checkbox on the specific condition. datagridTable.redraw() updates the view.

Edit: Looks like redraw() doesn't update the value of checkbox. Manually updating the value of CheckBoxCell should work. See updated code.

Pseudo-Code:

checkboxColumn.setFieldUpdater(new FieldUpdater<DataGridObject, Boolean>() {

    @Override
    public void update(int index, DataGridObject object, Boolean value) {
        if(specificCondition) {
            object.setCheckboxValue(false);
            checkboxCell.setViewData(object, false);
            datagridTable.redraw();
        }


    }
});

More info: FieldUpdater example on http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/cellview/client/DataGrid.html

Upvotes: 1

Related Questions