Sorting integer column

1 Answer 20 Views
Let's talk about telerik (the good and the bad) My glory with telerik controls
G
Top achievements
Rank 1
G asked on 12 Mar 2024, 02:33 PM | edited on 13 Mar 2024, 06:30 AM

I am using telerik version 2014.3.1024.45 with Asp.Net Webforms

I am using Telerik RadGrid. Columns are being sorted using string value. However if a particular column has integer values, it fails to sort properly. E.g. For the values 0, 1, 10, 2, 12, 3   It will sort as 0, 1, 10, 12, 2, 3

I tried setting 
DataType="System.Int32"   for column but still it considers as string. This column has on the fly values so I can not sort at database also.

Would appreciate any suggestion here. Is there any way to do it ? 

Thanks In advance

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 14 Mar 2024, 11:10 AM | edited on 14 Mar 2024, 11:11 AM

Hello G,

In ASP.NET (and in most programming languages) strings are treated as strings regardless if they are numbers. So they will be sorted alphabetically not numerically. 

If you'd like to sort numerically, you will need to bind Numeric (integer, decimal, double, etc.) values to the Grid. The DataType usually controls what filter functions are shown and how they treat the data. Sorting is done on the data source level, so if the data source contains strings, the data will be sorted alphabetically.

I hope this will help resolve the problem.

Regards,
Attila Antal
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
G
Top achievements
Rank 1
commented on 19 Mar 2024, 01:50 PM

Thanks for the information. This helps
Tags
Let's talk about telerik (the good and the bad) My glory with telerik controls
Asked by
G
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or