GWT: CheckBoxCell and Selection change event

4,176 views
Skip to first unread message

Qrunk

unread,
May 9, 2012, 6:30:25 AM5/9/12
to google-we...@googlegroups.com
I am using the following constructor to create a checkboxcell in an editable data grid.
  
    CheckboxCell(false, true)

When I use this and click at any place in the row, selection change event does not fire and I am using Single selection model .

When I use,

    CheckboxCell();

Selection change event fires on the row but,
1) We have click twice to check or uncheck the check box cell.
2) if we check or uncheck in the checkboxcell, the value will reverted as soon as I click anywhere.

I am trying to figure out the solution, but not successful yet. Any help would be appreciated.

Am using  GWT 2.4.0

Qrunk

unread,
May 9, 2012, 11:49:41 PM5/9/12
to google-we...@googlegroups.com
Any help on this issue will be very helpful

Qrunk

unread,
May 11, 2012, 1:01:53 AM5/11/12
to google-we...@googlegroups.com
Perhaps the question is not yet clear, I will try to rephrase it :

We are trying to create a DataGrid with editable cells, in which one of them is CheckBoxCell.we are using selection model as SingleSelectionModel .
Now this CheckboxCell takes two arguments in its constructor, i.e.

/**
   * Construct a new {@link CheckboxCell} that optionally controls selection.
   *
   * @param dependsOnSelection true if the cell depends on the selection state
   * @param handlesSelection true if the cell modifies the selection state
   */

  public CheckboxCell(boolean dependsOnSelection, boolean handlesSelection) {
}


Now after adding this CheckboxCell to one of the columns of the grid, it gets rendered with no problems.
But the following issues are noticed :

1) Here while adding the CheckboxCell we with no parameters with in the CheckboxCell constructor we get SelectionChangeEvent gets fired correctly, but in order to check/uncheck the checkbox we have to click twice on the check box cell. 
2) And while using

                Column<T, Boolean> checkCellGridColumn = new Column<T, Boolean>( new CheckBoxCell( false, true ){

SelectionChangeEvent is not fired.

What should be done so that I can get the check box checked at just one click and the selection event should also be fired on that click on the check box cell.

Thanks.

Thomas Broyer

unread,
May 11, 2012, 3:36:55 AM5/11/12
to google-we...@googlegroups.com
It's not clear to me what the checkbox "checkness" represents: is the checkbox used to select rows? or to set some boolean value of the row?

    // Checkbox column. This table will uses a checkbox column for selection.
    // Alternatively, you can call cellTable.setSelectionEnabled(true) to enable
    // mouse selection.
    Column<ContactInfo, Boolean> checkColumn = new Column<ContactInfo, Boolean>(
        new CheckboxCell(true, false)) {
      @Override
      public Boolean getValue(ContactInfo object) {
        // Get the value from the selection model.
        return selectionModel.isSelected(object);
      }
    };


The value of the cell depends on the selection state of the row object (dependsOnSelection=true) but the cell itself does not handle selection (it doesn't call setSelected() on the SelectionModel, but defers to the CellTable; hence handlesSelection=false)

Qrunk

unread,
May 11, 2012, 6:04:49 AM5/11/12
to google-we...@googlegroups.com
Hi Thomas,

Thanks for the reply. Actually we were trying the same thing what you had mentioned, but a piece of code missing at model level which was causing the problem.


Ajit Gupta

unread,
Jun 29, 2016, 4:49:05 AM6/29/16
to GWT Users
Hi 

I am facing same problem. Can you tell me what is problem in model level.
Reply all
Reply to author
Forward
0 new messages