Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight: Paging data from the server

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!

like image 814
ColinE Avatar asked Aug 09 '11 07:08

ColinE


2 Answers

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.

like image 108
stefan.s Avatar answered Nov 04 '22 10:11

stefan.s


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

like image 1
user381624 Avatar answered Nov 04 '22 08:11

user381624