2

I am using Kendo Grid in my asp.net mvc 4 project. I have the latest version of Kendo UI. One of the columns on the grid has data like (initially unsorted) ..

 MS1
 MS2
 MS3
 MS2345
 MS4

When I sort the column the data is displayed as ...

 MS1
 MS2
 MS2345
 MS3
 MS4

Instead of ...

 MS1
 MS2
 MS3
 MS4
 MS2345

This is what I am expecting when I sort the column.

What am I doing wrong?

Edit:

Based on the information I have been given so far (thanks guys), what I want to do is Natural Sort. I have more than 100,000 records in the database. I am doing all the sorting and filtering on the server-side due to the large number of records in the system.

Solution:

The following solution didnt work for me as our system is very large but just in case you wanna know.

Telerik guys replied saying "In order to do this you need to use custom binding. Then you would have full control over data operations such as paging and sorting. I found a few good resources how to implement natural sorting in .NET: http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting "

Oxon
  • 4,901
  • 8
  • 40
  • 54
  • 2
    The sorting order you are seeing is correct because the data is alphanumeric - this is how those values sort when sorted as strings. Are you doing your sorting server side or client side? – Stephen Byrne Oct 08 '13 at 19:48
  • Server side as there are too many records in the database. – Oxon Oct 09 '13 at 12:56

1 Answers1

4

As @StephenByrne said string sorting works as your result. In order to achieve what you are looking for you should perform "natural sort"

What you can do is: in kendo grid, make the column as non-sort-able. Then using JavaScript click event fire any of below approaches to perform "natural sort"

Here are few examples how you can achieve this

Community
  • 1
  • 1
HaBo
  • 13,999
  • 36
  • 114
  • 206
  • I have more than 100,000 records in the database. I am doing all the sorting and filtering on the server-side due to the large number of records in the system. – Oxon Oct 09 '13 at 12:55
  • you can do "natural sort" in C# or database see this example for natural sort in SQL Server http://stackoverflow.com/a/14869859/942855 – HaBo Oct 09 '13 at 13:27
  • We are using EF and kendo `.ToDataSourceResult(request)` for sorting/paging/grouping/etc. – Oxon Oct 15 '13 at 15:02
  • I am creating my grid thru MVC - and my understanding is that there is no way to bind custom JS sorting functions to an MVC grid, only one created in jQuery (source: https://www.telerik.com/forums/custom-sort-example-for-mvc-wrappers). Are you saying there is? And if so how would I get that done? – James L. May 31 '19 at 20:16