GWTCellTable
列仅逐页排序,对于每个页面,我必须单击列标题进行排序。如何在单击标题时对整个数据进行排序。这是我的代码,
dataProvider = new ListDataProvider<List<NamePair>>();
dataProvider.addDataDisplay(dgrid);
List<List<NamePair>> list = dataProvider.getList();
for (List<NamePair> contact : test) {
dataProvider.setList(test);
list.add(contact);
}
ListHandler<List<NamePair>> columnSortHandler = new ListHandler<List<NamePair>>(dataProvider.getList());
System.out.println("Column count->"+dgrid.getColumnCount());
for(int j=0 ; j<dgrid.getColumnCount();j++){
final int val = j;
columnSortHandler.setComparator(dgrid.getColumn(val), new Comparator<List<NamePair>>() {
public int compare(List<NamePair> o1, List<NamePair> o2) {
if (o1 == o2) {
return 0;
}
// Compare the column.
if (o1 != null) {
int index = val;
return (o2 != null) ? o1.get(index-2).compareTo(o2.get(index-2)) : 1;
}
return -1;
}
});
}
dgrid.addColumnSortHandler(columnSortHandler);