locked
Serverside paging RRS feed

  • Question

  • I have data getting called from a wcf service which I am returning paged.

    How do I use the PagedViewCollection and the DataPager when I am returning paged data. I've looking at the IPagedCollectionView I'm stuggling to understand it. I'm not sure where I put my data access get. Can anyone give me an overview of what I need to do.

    Friday, June 3, 2011 2:00 PM

Answers

  • Create "DataContract" which will contain your selected page data, say IEnumerable of the other DataContracts, and
    total count property of type "int" which will store total records count.
    Next, you'll create service method, which will perform data querying and paging, which returns instance of DataContract above.
    In markup you put DataPager and handle it's "PageIndexChanged". In that handler, you'll get selected page from DataPager
    and pass it so service method call (saying, which page you need to retrieve).
    In your service method "Completed" event handler you retrieve that DataContract instance, and check your DataPager "Source"
    property. If it's null or cast it to, say array of int, and length of that array is less than total count property of
    DataContract, assing to the Source property, say Enumerable.Range(0, e.Result.TotalCount), which will build all pages in your DataPager.
    That's pretty tricky, so I suggest to switch to WCF RIA Services

    Friday, June 3, 2011 6:34 PM

All replies

  • "DataPager" is usually used along with "DomainDataSource" controls, which is designed for working with WCF RIA Services.
    In this case WCF RIA Services automatically maintains data paging and loading.

    for details see:
    http://msmvps.com/blogs/theproblemsolver/archive/2009/04/27/paging-with-the-silverlight-ria-services-domaindatasource.aspx

    Friday, June 3, 2011 5:50 PM
  • I'm not using RIA. What are my options in regular Silverlight?

    Friday, June 3, 2011 6:09 PM
  • Create "DataContract" which will contain your selected page data, say IEnumerable of the other DataContracts, and
    total count property of type "int" which will store total records count.
    Next, you'll create service method, which will perform data querying and paging, which returns instance of DataContract above.
    In markup you put DataPager and handle it's "PageIndexChanged". In that handler, you'll get selected page from DataPager
    and pass it so service method call (saying, which page you need to retrieve).
    In your service method "Completed" event handler you retrieve that DataContract instance, and check your DataPager "Source"
    property. If it's null or cast it to, say array of int, and length of that array is less than total count property of
    DataContract, assing to the Source property, say Enumerable.Range(0, e.Result.TotalCount), which will build all pages in your DataPager.
    That's pretty tricky, so I suggest to switch to WCF RIA Services

    Friday, June 3, 2011 6:34 PM