tags:

views:

129

answers:

2

Hi,

I have a grid control in silverlight.I set up pagination for this control.Data is populated from db.I am trying to a sorting on all column headers.However sorting gets applied to specific page and does not apply to entire result set.How can this issue be fixed? Any suggesstions would be of great help.

Regards, Pri

+1  A: 

You can provide explicit IComparer implementations for the columns, as well as event handlers, to handle both questions.

Handle the click event on the header to resort your data however you like. http://www.longhorncorner.com/UploadFile/nipuntomar/SortingDataSilverlightDataGrid09152008025951AM/SortingDataSilverlightDataGrid.aspx

And leverage the ICollectionView IComparer implementation to do the sorting of the HyperLinks http://msdn.microsoft.com/en-us/library/system.windows.data.listcollectionview.aspx

(is the text of the hyperlinks all the same, e.g. ClickMe ?)

Also - since Silverlight is running on the client, has all the data been brought to it (or just that page's data, and paging is bringing data to the client)? eg what data source are you using? RIA Services and DomainDataSource? Or your own service calls?)

Bobby
A: 

You might want to use PagedCollectionView. PagedCollectionView gives you lot of functionality out of the box without writing much code.You can use it to sort the data,filter the data,group the data.

Get your data from server in the way you prefer and create a PagedCollectionView with the object collection retrieved from the server and bind the datagrid with PagedCollectionView.

You can sort the data by adding SortDescriptions.

It is explained with examples at MSDN. Especially look for sort section.

Hope this helps.

funwithcoding