Open GoogleCodeExporter opened 8 years ago
Note that you also need to update SortableGrid. I'm using this implementation:
public class CustomFixedWidthGrid extends FixedWidthGrid {
private Map<Integer, ColumnSorter> column2columnSorter = new HashMap<Integer,
ColumnSorter>();
public void setColumnSorter(int column, ColumnSorter columnSorter) {
column2columnSorter.put(column, columnSorter);
}
/**
* Sort the grid according to the specified column.
*
* @param column the column to sort
* @param ascending sort the column in ascending order
* @throws IndexOutOfBoundsException
*/
public void sortColumn(int column, boolean ascending) {
// Verify the column bounds
if (column < 0) {
throw new IndexOutOfBoundsException(
"Cannot access a column with a negative index: " + column);
}
if (column >= numColumns) {
throw new IndexOutOfBoundsException("Column index: " + column
+ ", Column size: " + numColumns);
}
// Add the sorting to the list of sorted columns
getColumnSortList().add(new TableModel.ColumnSortInfo(column, ascending));
ColumnSorter columnSorter = column2columnSorter.get(column);
if (columnSorter == null) {
columnSorter = getColumnSorter(true);
}
// Use the onSort method to actually sort the column
columnSorter.onSortColumn(this, getColumnSortList(),
new ColumnSorterCallback());
}
}
Original comment by devun...@gmail.com
on 9 Nov 2008 at 3:09
I'd prefer to add column sort capabilities to dedicated typed ColumnDefinition
classes.
These typed column sorters could be used in ScrollTable in the same way as I
apply
the filters.
Original comment by daniel.florey@gmail.com
on 11 Nov 2008 at 10:01
Original comment by ecc%google.com@gtempaccount.com
on 1 Dec 2008 at 5:49
I've tried to use the code above, but I fail to instansiate ColumnSorterCallback
since this constructor is protected.
Original comment by trond.an...@gmail.com
on 2 Sep 2009 at 2:32
Original issue reported on code.google.com by
devun...@gmail.com
on 8 Nov 2008 at 8:14