Completed
Last Updated: 04 Feb 2021 16:55 by ADMIN
NovaStor
Created on: 18 Apr 2020 22:52
Category: Grid
Type: Feature Request
2
Multiple column grid sort mode., allow unsorted, but must have at least one column sorted

Hi.

 

I'd like to request the ability to sort on multiple columns of a grid, allow unsorting a column, but the grid must have at least one columns sorted.

 

An exception is thrown when calling `ToDataSourceResult` from the `Kendo.DynamicLinq` library if there are no columns sorted:

System.NotSupportedException: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'

 

Thank you.

4 comments
NovaStor
Posted on: 03 May 2020 08:31

Thank you.

I'm able to manually resolve the issue by using a default order column if no sort columns are specified in the request.

ADMIN
Viktor Tachev
Posted on: 30 Apr 2020 14:44

Hello,

 

Thank you for the provided project. I examined it and noticed that it was using Kendo.DynamicLinq. Note that this is part of an experimental project that has not been updated for a while. If you would like to handle operations like paging and sorting manually with the Grid I suggest using an approach similar to the one from the example below:

https://demos.telerik.com/aspnet-mvc/grid/customajaxbinding

 

That said, the error you are seeing is because of an Entity Framework requirement. In order to call Skip() the data needs to be sorted before that. The stackoverflow thread elaborates on the error:

https://stackoverflow.com/questions/3437178/the-method-skip-is-only-supported-for-sorted-input-in-linq-to-entities

 

Regards,
Viktor Tachev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
NovaStor
Posted on: 26 Apr 2020 21:31

I've attached a solution which can reproduce the issue.

Because files are limited to 20mb I had to remove the following:

1. .\lib\KENDOUIMVC\2020.1.114.545

     For example, Kendo.Mvc.dll

2. .\ToDataSourceResultWithoutSortedColumns\Scripts\kendo\2020.1.114

     For example, kendo.all.min.js

 

After those files are restored, here are the steps to reproduce:

1. Open ToDataSourceResultWithoutSortedColumns.sln in Visual Studio 2017

2. Build solution

3. Open project's properties > Web > Servers > select "Local IIS" and click "Create Virtual Directory"

4. Open IIS Manager

5. Create a new Application Pool with the following properties:

Name: ToDataSourceResultWithoutSortedColumns

.NET CLR: 4.0

Enable 32-bit Applications: true

Managed Pipeline Mode: Integrated

Identity: LocalSystem

6. Right-click "ToDataSourceResultWithoutSortedColumns" virtual directory >  Manage Application > Advanced Settings... > Application Pool > set to "ToDataSourceResultWithoutSortedColumns"

7. Debug project

8. Click on the "Order Date" column (to un-sort it)

9. The debugger will break on the exception:

System.NotSupportedException: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.

Thank you.

ADMIN
Viktor Tachev
Posted on: 24 Apr 2020 18:54

Hello,

 

I tried reproducing the issue with our Grid Sorting example, however, the Grid is sorted as expected. Would you send us a sample project where the issue is replicated so we can examine it and look for what is causing the behavior?

 

Regards,
Viktor Tachev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.