Tuesday, November 11, 2014

Re: Select All Behavior on CheckboxCell

Just add a ClickHandler to your button that does this when clicked:

for (MyProxy proxy: dataProvider.getList()) {
   selectionModel.setSelected(proxy, true);
}

where selectionModel is a MultiSelectionModel and dataProvider is your table's data provider.
Your checkBoxes will be checked/unchecked in sync with the selectionModel if you set it up like this:

Column<MyProxy, Boolean> checkColumn = new Column<MyProxy, Boolean>(new CheckboxCell(true)) {
   @Override
   public Boolean getValue(MyProxy object) { 
      return selectionModel.isSelected(object);
   }
}; 
checkColumn.setFieldUpdater(new FieldUpdater<MyProxy, Boolean>() {
   public void update(int index, MyProxy object, Boolean value) { 
      selectionModel.setSelected(object, value);
   }
}); 

On Friday, November 7, 2014 4:53:33 PM UTC-7, Gustavo Ponce wrote:
Hi Guys,

I have a CellTable with a "com.google.gwt.cell.client.CheckboxCell" column, I would like to implement a "select all/deselect all" behavior when the user clicks a specific button.

What is the best way to implements this?

Thanks

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment