I have a server-side API which provides paged data in JSON format based on various query parameters. I would like to provide a UI that allows the user to paged through the results of a query.
I am aware of the various component parts that permit this sort of interface, IPagedCollectionView and ICollectionView at the model / view model lever and DataPager within the UI. However, all the examples I have seen implement paging on top of data which has already been loaded into the model or view model.
I was hoping to find an IPagedCollectionView implementation somewhere, where you simple plug in your 'fetcher' method that fetches a given page of data from the server, plus provides a bit of metadata (total pages etc ...)
I could write this myself based on the IPagedCollectionView and ICollectionView interfaces, but I would be surprised if there is not a standard solution to this problem.
Any pointers to more suitable parts of the framework or libraries that extend the framework would be appreciated!
We had the same question and we settled with the new DomainCollectionView which is part of the WCF RIA Services SP1. Which of couse means you have to use RIA Services, don't know if that's an option.
The DomainCollectionView (which already implements the desired IPagedCollectionView interface) comes in combination with a DomainCollectionViewLoader which can be used to fetch the data for the current page.
For me this blog post by Kyle McCellan was very helpful:
http://blogs.msdn.com/b/kylemc/archive/2010/12/02/introducing-an-mvvm-friendly-domaindatasource-the-domaincollectionview.aspx
[Update] You may also find this Blog post helpful:
http://weblogs.asp.net/manishdalal/archive/2009/10/01/silverlight-3-custom-sorting-with-paging-support.aspx
It is a custom implementation of the IPagedCollectionView interface. We use it in one place where we aggregate Data from different datasources and a DomainCollectionView was not applicable.
You could try WCF data services, which can feed json i believe. it has an api for 'continuations' which are effectively paged queries. It might feel a bit strange for you to use this as a wrapper, but I'm sure you could make it work.
http://blogs.msdn.com/b/writingdata_services/archive/2011/02/25/getting-json-out-of-wcf-data-services.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With