ColumnSortEvent#getColumn() returns the Column that was sorted.  You can
resolve it back to an index if needed using
CellTable#getColumnIndex(Column).

cellTable.addColumnSortHandler(new ColumnSortEvent.Handler() {
 public void onColumnSort(ColumnSortEvent event) {
*   Column<T, ?> sortedColumn = event.getColumn();*
*   int sortedIndex = cellTable.getColumnIndex(sortedColumn).*
  ...
   List<T> newData = new ArrayList(cellTable.getVisibleItems()); // Cop the
data
   if (event.isSortAscending) {
     Collections.sort(newData, myAscComparator); // Sort ascending.
   } else {
     Collections.sort(newData, myDescComparator); // Sort
descending.
   }
   cellTable.setRowData(cellTable.getVisibleRange(), newData);
 }
});


Thanks,
John LaBanca
[email protected]


On Mon, Feb 21, 2011 at 1:13 PM, 1111ichiro <[email protected]> wrote:

> I am following this code snippet that I found in this forum to sort
> dynamic data locally one page at a time.
>
> cellTable.addColumnSortHandler(new ColumnSortEvent.Handler() {
>  public void onColumnSort(ColumnSortEvent event) {
>    List<T> newData = new ArrayList(cellTable.getVisibleItems()); //
> Copy
> the data
>    if (event.isSortAscending) {
>      Collections.sort(newData, myAscComparator); // Sort ascending.
>    } else {
>      Collections.sort(newData, myDescComparator); // Sort
> descending.
>    }
>    cellTable.setRowData(cellTable.getVisibleRange(), newData);
>  }
>
>
>
> });
>
>
> However, I am unable to figure out for which column the sort event is
> fired. Even if I let the sorting happens on the server, I still need
> to know which column.
>
> Please help me out with  a code example.
>
> Thank you very much
>
>
> 1111ichiro.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to