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

SL4 RadGridView Sorting and RIA, EF and DataPager

3 Answers 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eric Lincoln
Top achievements
Rank 1
Eric Lincoln asked on 28 Jan 2010, 06:53 PM

I'm using Telerik SL4 (2009 3 1314 1030) RadGridView with RIA Services, EF 4.0 and an MS SL4 DataPager. I set the initial RIA sort descriptors in the xaml but these can be overwritten by clicking on any given grid column header. An RIA error occurs when the user by clicking on a header changes that column's sort descriptor  to None. The reason for this error is the Telerik grid removes all sort descriptors from the DDS. The RIA service and EF requires that the DDS has at least one sort descriptor when its used in conjunction with a DataPager. This error can be avoided if when handling the DDS' OnDataLoading event it is verified that there is at least one SortDescriptor set before fetching more data for a new page. The main problem with this is the page in view when the user specified the 'None' sort descriptor is unsorted but all other pages are sorted per the descriptor supplied in the OnDataLoading handler. I tried to resolve this by creating a grid sorting event handler that changes a sort descriptor from none to a descriptor equivalent to the one assigned the DDS in the DataLoading handler so even the initial page is sorted.

The best solution would be for Telerik to allow client side sorting to be configured to disallow the 'None' sort descriptor. Second best allow the grid sorting handler to pre-empt the selection of a 'None' sort descriptor.

Currently the best solution is to block client side sorting altogether.

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan Dobrev
Telerik team
answered on 29 Jan 2010, 08:02 AM
Hi Eric Lincoln,

Have you tried to sort by default on the server? Here is an example of a simple domain service method that does this:
public IQueryable<Product> GetProducts()
{
    return this.ObjectContext.OrderBy(p => p.ProductID);
}

This way you will "workaround " the EF limitation on the server and the sorting with paging will correctly on the client.

Best wishes,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Eric Lincoln
Top achievements
Rank 1
answered on 29 Jan 2010, 08:02 PM
Stefan,
I took your advice and the grid's client sorting now works as expected. Thank you for your timely and accurate response.
Eric
0
GEB
Top achievements
Rank 1
answered on 02 Feb 2010, 03:52 PM
I solved the issue a bit differently.  On the client side, I handle the event from the RadGridView when it is about to sort.  If the sort type is NONE (sent in the event), I change the sort type to be either ascending or descending.  In this way, the user nevers knows that there is a sort type of NONE, and I did not have to implenent default server-side sorting.
Tags
GridView
Asked by
Eric Lincoln
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Eric Lincoln
Top achievements
Rank 1
GEB
Top achievements
Rank 1
Share this question
or