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

About sorting and paging

2 Answers 20 Views
DataServiceDataSource
This is a migrated thread and some comments may be shown as answers.
Max
Top achievements
Rank 1
Max asked on 17 Dec 2013, 11:53 AM
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 Answers, 1 is accepted

Sort by
0
Max
Top achievements
Rank 1
answered on 18 Dec 2013, 09:57 AM
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.
0
Maya
Telerik team
answered on 19 Dec 2013, 02:19 PM
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 >>
Tags
DataServiceDataSource
Asked by
Max
Top achievements
Rank 1
Answers by
Max
Top achievements
Rank 1
Maya
Telerik team
Share this question
or