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

[Solved] RadGrid sorting does not work on all types of data sources

3 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sjoerd
Top achievements
Rank 1
Sjoerd asked on 14 Dec 2012, 10:04 AM
I am using the default RadGrid sorting feature, but it only works in some cases. For example:

<telerik:RadGrid runat="server" ID="NumbersGrid" AllowSorting="true" OnNeedDataSource="NeedNumbers" />
protected void NeedNumbers(object sender, GridNeedDataSourceEventArgs e)
{
    ((RadGrid)sender).DataSource = Enumerable.Range(1, 10).Select(number => new { number });
}

This displays 10 numbers in a grid, as you would expect. If you click on the header, a sorting arrow appears but the grid does not actually become sorted. How come?

I am using Telerik 2012.1.

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 19 Dec 2012, 08:03 AM
Hello Sjoerd,

I have created a sample RadGrid web site to test the described behavior. On my side everything works as expected and the grid content is sorted correctly. Please check out the attached application and let me know about the result.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Sjoerd
Top achievements
Rank 1
answered on 19 Dec 2012, 09:12 AM
Thanks Eyup, for your response.

I tried the example project you supplied. I copied the files into an empty website project and added references to Telerik. It did not work. It still did not do any sorting, and keeps showing the numbers 1 through 5.

I then tried with Telerik 2012.3 v1218. This works correctly. It seems like this issue is already solved. We will be using this newer version in the future, thank you for your help.
0
Jeff
Top achievements
Rank 1
answered on 18 Mar 2013, 07:16 PM
Looks like you've already solved your issue... but for those with the same issue who can't/don't want to upgrade; I've found that this issue is resolved by merely adding a .ToList() call do the end of the Linq chain. Not sure exactly why the sort and filtering are failing on the IEnumerable(T) directly.
Tags
Grid
Asked by
Sjoerd
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Sjoerd
Top achievements
Rank 1
Jeff
Top achievements
Rank 1
Share this question
or