Forgot to mention that an example of both ListDataProvider and
AsyncDataProvider can be found here:
- http://code.google.com/intl/da/webtoolkit/doc/latest/DevGuideUiCellTable.html

We think that the sorting inside the AsyncDataProvider breaks the idea
of separation of view and data.

Or have we totally misunderstood when to use AsyncDataProvider vs
ListDataProvider? Or how sorting is implemented.

On 27 Sep., 16:41, jgm <[email protected]> wrote:
> Hello,
>
> We are using an async dataprovider in our celltable, and we have had
> some problemt gettting the sorting to work.
>
> In the OnRangeChanged method, we implement sorting this way:
>
> if (sortList.get(0).getColumn().equals(costManagementNameColumn)) {
>         Collections.sort(effectConfigurationCache, new
> Comparator<EffectConfiguration>() {
>                 public int compare(EffectConfiguration o1, 
> EffectConfiguration o2) {
>                         if (o1 == o2) {
>                                 return 0;
>                         }
>                         // Compare the cost management name columns.
>                         int diff = -1;
>                         if (o1 != null) {
>                                 diff = (o2 != null) ?
> o1.getCostManagementName().compareTo(o2.getCostManagementName()) : 1;
>                         }
>                         return sortList.get(0).isAscending() ? diff : -diff;
>                 }
>         });} else if (sortList.get(0).getColumn().equals(orgUnitNameColumn)) {
>
>         Collections.sort(effectConfigurationCache, new
> Comparator<EffectConfiguration>() {
>                 public int compare(EffectConfiguration o1, 
> EffectConfiguration o2) {
>                         .....
>                         .....
>                 }
>         });} else if 
> (sortList.get(0).getColumn().equals(effectTypeNameColumn)) {
>
>         Collections.sort(effectConfigurationCache, new
> Comparator<EffectConfiguration>() {
>                 public int compare(EffectConfiguration o1, 
> EffectConfiguration o2) {
>                         ......
>                         .....
>                 }
>         });} else if 
> (sortList.get(0).getColumn().equals(maximumThresholdColumn))
>
> {
>         Collections.sort(effectConfigurationCache, new
> Comparator<EffectConfiguration>() {
>                 public int compare(EffectConfiguration o1, 
> EffectConfiguration o2) {
>                         ......
>                         .....
>                 }
>         });
>
> }
>
> This seems to be quite cumbersome !
> Can this be done more elegantly?
>
> Previously we used the ListDataProvider, and here sorting is
> implemented directly on the ListHandler by setting a comparator for
> each column, wich we think is a elegant way to do it!

-- 
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