GWT 2.2 CellTable sorting

276 views
Skip to first unread message

Jerome Thoma

unread,
Mar 14, 2011, 5:59:50 AM3/14/11
to google-we...@googlegroups.com
Hi everyone,
I recently upgraded to GWT and I am currently adding table sorting to my application. Everything works fine except that after a refresh of my data, no sorting is applied until the user clicks on the column header. I am using a ListDataProvider and neither adding data to the list nor changing data seems to trigger a re-sort event. Do I have to trigger this myself? And how can I create a ColumnSortEvent?

Have a nice day,
Jerome Thoma

John LaBanca

unread,
Mar 14, 2011, 11:01:36 AM3/14/11
to google-we...@googlegroups.com, Jerome Thoma
If you are using an AsyncDataProvider, call CellTable#getColumnSortList() when you refresh the data to get the currently sorted column, then request the data in sorted order.

If you are using a ListDataProvider, you can sort the list manually at any time:
Collections.sort(dataProvider.getList(), myComparator).

CellTable just assumes that any data being pushed into the CellTable is already sorted.

Thanks,
John LaBanca
jlab...@google.com


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

3xM

unread,
Apr 25, 2011, 9:05:57 AM4/25/11
to Google Web Toolkit
> If you are using a ListDataProvider, you can sort the list manually at any
> time:
> Collections.sort(dataProvider.getList(), myComparator).

hi,
that is what i am doing, no problem sorting result before adding it to
ListDataProvider, but:
i have two columns, and user clicks on a first column header and
sorts. after that user calls new data, i fetch them, sort (by second
column!) and add to ListDataProvider.
table shows data sorted by second column, thats ok, but sort indicator
is still in the header of first column.

or, imagine i want users to sort by clicking buttons (outside table),
not just clicking on headers. i can do that by sorting data provider's
list, and table get sorted, but there's no arrow showing by what
column is table sorted.
Reply all
Reply to author
Forward
0 new messages