views:

282

answers:

1

I need to be able to load a page of results into the grid from many tens of thousands of possible results. I want to get the data in pages of fifty from the server, using SQL Server to sort the data before returning it for binding to the datagrid. When the user sorts the dta in the datagrid by clicking a column header, I need to detect this and determine the new order before going back to the database.

A: 

I Don't think there is a way to ask the datagrid on what column it is sorted. However looking at http://blogs.msdn.com/scmorris/archive/2008/06/10/sorting-data-in-the-silverlight-datagrid.aspx I see that you can implement your own sorting when you implement ICollectionView on your items.

So you maybe you could implement ICollectionView on (a wrapper around) your results?

Datagrid does this internally if you set it's ItemSource to an IList, so maybe you can take a look at it's implementation to see how they did it? (see the Datagrids internal class ListCollectionView using reflector)

When you have a ICollectionView, you can use it's SortDescriptions to find out the current sorting.

I hope this helps you in the right direction?

Tjipke

Tjipke