Sorting RadGridView with RadDataPager

2 posts, 1 answers
  1. Joao Paulo Grassi
    Joao Paulo Grassi avatar
    98 posts
    Member since:
    Feb 2011

    Posted 26 Dec 2011 Link to this post

    Hello!

    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?

    Thanks
  2. Answer
    Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 26 Dec 2011 Link to this post

    Hello,

    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 http://services.odata.org/Northwind/Northwind.svc/Customers()?$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.

    Regards,
    Ross
    the Telerik team

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

  3. DevCraft banner
Back to Top