About sorting and paging

3 posts, 0 answers
  1. Max
    Max avatar
    2 posts
    Member since:
    Apr 2013

    Posted 17 Dec 2013 Link to this post

    As others I had to sort before the RadDataPager paging takes action so I solved like this:
    • I created the MyNorthwindContext like in the documentation
    • Then I added a property with my sort, something like
      public class MyNorthwindContext : NorthwindEntities
      {
          public MyNorthwindContext() : base(new Uri("http://services.odata.org/Northwind/Northwind.svc", UriKind.Absolute)){}
       
          public DataServiceQuery<Category> SortedCategories
          {
              get
              {
                  if ((this._SortedCategories == null))
                  {
                      this._SortedCategories = base.CreateQuery<Category>("Categories")
                          .AddQueryOption("$orderby", "CategoryID desc");
                  }
                  return this._SortedCategories;
              }
          }
          private DataServiceQuery<Category> _SortedCategories;
      }

    • so

      <telerik:RadDataServiceDataSource Name="categoriesDataSource" QueryName="SortedCategories" AutoLoad="True">

    Is that ok?
  2. Max
    Max avatar
    2 posts
    Member since:
    Apr 2013

    Posted 18 Dec 2013 Link to this post

    No, it is not.
    RadGridView sorting will cause exception.

    So, in a situation like this
    if I want to start with a grid ordered by CustomerID I found useful start with a RadDataServiceDataSource AutoLoad set to false,
    set my sort descriptor, than, when DataPager.Loaded occours, invoke Load() on the RadDataServiceDataSource and set AutoLoad to true.

    Any better solution is welcome.
  3. DevCraft banner
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 19 Dec 2013 Link to this post

    Hi Max,

    You can also take a look at this forum thread for further reference.
    I hope that helps.

    Regards,
    Maya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top