Saturday, April 19, 2014

How to sort CheckBox Column of cellTable in GWT?

I know how to sort the TextColumn of cellTable in GWT.

That is setSortable(true) for textColumn

then declare ListHandler<String[]> columnSortHandler = new ListHandler<String[]>(myTableList);

then columnSortHandler.setComparator(textColumn, new MyCellTableColumnComparator(1));,

finally getView().getMyCellTable().addColumnSortHandler(columnSortHandler);

But what if we have CheckBox column & we want to sort CheckBox column. That is when user clicks the header of CheckBox column it will bring all the rows that has CheckBox checked to top. If user clicks the header of CheckBox column again it will bring all the rows that has CheckBox unchecked to top. So there are only 2 possible options for sorting CheckBox column, that is checked & unchecked.

We declare CheckBox column as following:

Column<String[], Boolean> checkBoxColumn = new Column<String[], Boolean>(                          new CheckboxCell(true, false)) {    @Override    public Boolean getValue(String[] object) {        return mySelectionModel.isSelected(object);    }  };    ckColumn.setSortable(true);  

But then how can we setComparator for checkBoxColumn?

Or can you find a better solution?

also: http://stackoverflow.com/questions/23171925/how-to-sort-checkbox-column-of-celltable-in-gwt


--
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