Hi,

I tried to discuss this in the GWT google groups, but I did not get any 
feedback there. I figured since this was a strange design choice in GWT 
that I should discuss it here:

I just lost 2 hours on getting client side sorting to work correctly in my 
DataGrid backed by a ListDataProvider. I was using the 
ColumnSortEvent$ListHandler class that was mentioned in the documentation 
to handle the client-side sorting.
 
I was calling setList( rows ) on the DataProvider to update the table. When 
you call setList, the DataGrid is being updated correctly. But clicking on 
a column to sort (client side) does not work, nothing is being sorted.

I did some investigation an the problem is actually very simple. The The 
ColumnSortEvent$ListHandler class takes a List as argument instead of the 
ListDataProvider. When you call setList() on the DataProvider a new wrapper 
is created and so the ListHandler is looking at the wrong one (the empty 
list in my case hence no sort effect at all).
 
Wouldn't it be better that the ListHandler would keep a reference to the 
ListDataProvider instead of using the List ? Then it can call getList() on 
it when a sort is needed.
 
It is now a bit asymetric: calling setList() updates the table rows, but 
the sorter does not know... I am sure many many people fall in this trap!
At least the documentation should maybe point this out. I just replaced the 
ListHandler with my own that just calls getList() on the ListDataProvider 
everytime a sort is needed, that works completely transparently. I don't 
want to create and reconfigure a ListHandler every time I update the table 
data. 

calling clear() and addAll() is an alternative, but it is awkward and 
should at least be documented.

David

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to