Thursday, February 24, 2011

Re: CheckboxCell 2 clicks for selection

Thank you very much Y2i.
I´ve got it solved. For users with the same problem:
The problem was int he logic that you have to handle in the getValue method of the column.
MyModel has a Boolean field used to represent whether the checkbox should be checked or not in the first presentation of the table. The table has to behave like this:
 - If the checkbox IS not selected and you click it, then the row becomes selected and the checkbox clicked.
 - If the checkbox IS NOT selected and you click it, then the checkbox becomes clicked (the state of the row remains unchanged, i.e. unselected).
So the logic to handle this:

    Column<MyModel , Boolean> checkColumn = new Column<MyModel, Boolean>(new CheckboxCell(true,false)) {
      @Override
      public Boolean getValue(MyModel myModel) {
      if(selectionModel.isSelected(myModel)  &&  myModel.isValid()) {
      myModel.setValid(false);
      selectionModel.setSelected(myModel, false);
      }
      return selectionModel.isSelected(myModel) || myModel.isValid();
      }
    };


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment