Set default sort order for initial header click on gwt cell table

ahaurw01 picture ahaurw01 · Feb 29, 2012 · Viewed 8.3k times · Source

I have a GWT CellTable with sortable columns very similar to the developer's guide example (http://code.google.com/webtoolkit/doc/latest/DevGuideUiCellTable.html#columnSorting).

However, I would like to have certain columns sort descending instead of ascending by default. That is, if column A is not currently sorted and I click on it's header, I want column A to be sorted descending on that first click and ascending on the second click. But I do still want other columns to sort as they currently do - using ascending order on the first click.

Aside from the Column.setSortable(boolean) method to set sortability and the ColumnSortList.push(ColumnSortInfo) method to manually trigger a sort, there doesn't seem to be much control over the process.

Is there a way to accomplish this goal?

Answer

smjZPkYjps picture smjZPkYjps · Aug 25, 2012

Column.setDefaultSortAscending(false) is the easy way to do this; no custom CellTable required.