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