What I was getting confused about doing it this way though is if I'm
allowing the data to be sorted by 4 or 5 different columns, would I
have to say something like:

if (event.isSortAscending && nameColumn) {
    Collections.sort(newData, nameAscComparator)
} else if (nameColumn) {
    Collections.sort(newData, nameDescComparator)
} else if (event.isSortAscending && timeRequestedColumn) {
    Collections.sort(newData, timeRequestedAscComparator)
} ....

ya know where I have to have a different asc and desc comparator for
each column and figure out which column was selected before I sort?

I'm thinking that I'll have a small enough set of rows (probably max
100 rows at a time), that if I just make the columns sortable, it will
be fine if I don't use paging. So maybe I should do what Greg
mentioned and download all the data and use a ListDataProvider. What I
liked about the AsyncDataProvider though is that people can change the
value of a cell and hit enter and it's updated in the database because
this will be an application a couple are using at one time all dealing
with the same data so I need changes to show up on what other people
are seeing.

BTW, thanks a lot guys!

On Feb 14, 10:00 am, John LaBanca <jlaba...@google.com> wrote:
> If you are supporting paging, then a local sort will only sort the current
> page, whereas a database sort would sort the data return the results for the
> current page.  For example, if you are on the first page and do a reverse
> sort, do you want to see all the names that start with z (database sort), or
> do you want to see all of the names that start with a in reverse order
> (local sort of the current page).
>
> That being said, you can cache the values locally in a list and use
> ListSortHandler.  Alternatively, you can add a ColumnSortEvent.Handler to
> CellTable and copy and sort the return of CellTable#getVisibleItems().  The
> code would be something like the following:
>
> 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);
>   }
>
> });
>
> Thanks,
> John LaBanca
> jlaba...@google.com
>
>
>
>
>
>
>
> On Mon, Feb 14, 2011 at 12:53 AM, Josh K <kendrick.j...@gmail.com> wrote:
> > I've been developing an application in GWT that has data I've been
> > displaying in a CellTable. I've set it up with a few TextColumns and a
> > few EditTextColumns. I've got it set up to where if someone changes
> > the data in an EditText cell, it sends an asynchronous request to the
> > database and updates that row in the DB table. In short, I've got all
> > this working using AsyncCallbacks and an AsyncDataProvider.
>
> > Since 2.2 came out, I want to implement column sorting, kind of like
> > is seen in this example:
> >http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellTable
> > , but with an AsyncDataProvider. I want to sort the columns locally
> > because I think it'd be faster than making an Async DB call again each
> > time someone clicks to sort (which is the impression of what was
> > supposed to happen if I used an AsyncHandler.
>
> > So I THINK what I'm looking for is some way to use a ListHandler with
> > an AsyncDataProvider?
>
> > Can anyone shed some light on this? Maybe done it before or know the
> > direction I'm supposed to? If it's even do-able?
>
> > --
> > 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-web-toolkit@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-toolkit+unsubscr...@googlegroups.com.
> > 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 google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to