Link to home
Start Free TrialLog in
Avatar of Labelsoft
LabelsoftFlag for Netherlands

asked on

WCF dataservice serverside paging and silverlight datagrid clientside paging?

Dear experts,

I have a WCF DataService with an ADO.NET Entity Framework model which is set on our test DB with 1 table in it called "Patient". This table contains 11000 records so I can test 'paging'. I've turned paging on in this service to 10 records ("config.SetEntitySetPageSize("Patients", 10)").

I have a client application in Silverlight which has a DataGrid. I've been able to set clientside paging on by using a PagedCollectionView and a DataPager.

The problem however is that this makes the serverside paging useless. Because now I have to retrieve all 11000 records 10 at a time (which is like 20 seconds delay or something) for the paging on the DataGrid to work (DataPager needs the full collection before it can calculate the number of pages ofcourse).

Isn't there a way to solve this elegantly? Basically what I want is for the datagrid to be able to retrieve the next 10 records from the WCF dataservice when the user presses 'next' on the DataPager.
ASKER CERTIFIED SOLUTION
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Labelsoft

ASKER

First off, excuse me for the delay. I've been puzzling with a colleague since you posted to figure it out.

We've finally got this stuff to work. It was for the most part link #2 you provided, so you'll get the credits.

We wanted it declarative in XAML because we want to use MVVM pattern on the client. In retrospect it made stuff quite complicated at first. Now we've got it to work it's quite simple (all thnx to WCF and Silverlight 4).

Quickly the basic steps (if anybody is interested in the exact details please feel free to contact us):

- Set up DomainService
- Give it the method to call (like for instance: GetCustomers())
- Set up DomainDataSource in XAML
- Hook up DataPager to DomainDataSource
- Hook up Grid to DataPager
- Override Count in DomainService if you want total pages on DataPager

Note: If you work with large datasets, don't forget to set up your web.config accordingly (maxReceivedMessageSize="2147483647" and maxItemsInObjectGraph="10000000" for instance).

Ok thnx! And again, contact us for details if you need it.
Thanks for giving the details on your approach. I do know that DomainDataSource has an element in XAML.  Also I m not sure if you know about this but you could pass the UI element to VM through commanding whether its PRISM or MVVM light.  I agree but it would not be the best practice though as there would not be advantage of using MVVM but just an idea. MVVM is more like a discipline you should stick to in whatever may be the scenario.
Well, to be honest, we haven't given it much thought. Now we realize that DomainDataSource and MVVM are not compatible. We are basically going to try to put the logic that the DDS does for you in a VM. It's not going to be easy, but we are going to try.