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?