This is a migrated thread and some comments may be shown as answers.

Sorting RadGridView with RadDataPager

1 Answer 80 Views
This is a migrated thread and some comments may be shown as answers.
Missing User
Missing User asked on 26 Dec 2011, 01:15 PM

I'm using the RadDataServiceDataSource with RadGridView and RadDataPager, everthing is working fine except one thing. My DataServiceDataSource's query is a View located in my model file. Since ORDER BY clauses are not allowed in Views, I try to use SortDescriptor to sort the Items on GridView Ascending when it is loaded.

But when I test it, the data comes in a strange way, Example, my DataPager is set up to show 30 records per page, But with the SortDescriptor every page comes With "A" in it's start.

Is there a way to Sort the records in the GridView with DataPager and DataServiceDataSource?


1 Answer, 1 is accepted

Sort by
Rossen Hristov
Telerik team
answered on 26 Dec 2011, 01:47 PM

This online demo does exactly what you want. Make sure that you wire the controls like in the demo in order to do both the sorting and the paging on the server like shown in this example. You can see what queries are being sent to the server as demonstrated in the online example or with a tool such as Fiddler or Firebug or SQL Server Profiler.

When you sort the grid and have paging you should be seeing something like this:

--> Requesting$orderby=ContactName&$skip=10&$top=10&$inlinecount=allpages

The yellow stuff is the sorting which happens before paging (the orange stuff).

By the way, the RadDataServicesDataSource does nothing magical or special. It simply build this OData query and sends it to the server. If the server returns "wrong" data then there is nothing we can do about that.

I hope this helps.

the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Asked by
Missing User
Answers by
Rossen Hristov
Telerik team
Share this question