Re: Column sorting using async dataprovider in celltable
AFAIK, AsyncDataProvider is designed for requesting a small page of data to be displayed from a potentially large dataset via RPC. In this scenario you would usually want to pass the sort order(along with the range) to the RPC service, so it can sort on the whole dataset, rather than just the current page. On Thu, Sep 29, 2011 at 2:23 PM, jgm wrote: > 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 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() { >> 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() { >> public int compare(EffectConfiguration o1, >> EffectConfiguration o2) { >> . >> . >> } >> });} else if >> (sortList.get(0).getColumn().equals(effectTypeNameColumn)) { >> >> Collections.sort(effectConfigurationCache, new >> Comparator() { >> public int compare(EffectConfiguration o1, >> EffectConfiguration o2) { >> .. >> . >> } >> });} else if >> (sortList.get(0).getColumn().equals(maximumThresholdColumn)) >> >> { >> Collections.sort(effectConfigurationCache, new >> Comparator() { >> 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. > > -- 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.
Re: Column sorting using async dataprovider in celltable
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 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() { > 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() { > public int compare(EffectConfiguration o1, > EffectConfiguration o2) { > . > . > } > });} else if > (sortList.get(0).getColumn().equals(effectTypeNameColumn)) { > > Collections.sort(effectConfigurationCache, new > Comparator() { > public int compare(EffectConfiguration o1, > EffectConfiguration o2) { > .. > . > } > });} else if > (sortList.get(0).getColumn().equals(maximumThresholdColumn)) > > { > Collections.sort(effectConfigurationCache, new > Comparator() { > 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.
Column sorting using async dataprovider in celltable
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() { 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() { public int compare(EffectConfiguration o1, EffectConfiguration o2) { . . } }); } else if (sortList.get(0).getColumn().equals(effectTypeNameColumn)) { Collections.sort(effectConfigurationCache, new Comparator() { public int compare(EffectConfiguration o1, EffectConfiguration o2) { .. . } }); } else if (sortList.get(0).getColumn().equals(maximumThresholdColumn)) { Collections.sort(effectConfigurationCache, new Comparator() { 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.