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

Swedish sorting

4 Answers 309 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fredrik
Top achievements
Rank 1
Fredrik asked on 19 Dec 2017, 12:04 PM

Hello!

I have a question about sorting string columns in the RadGridView component.

Lets say I have the following rows;

  • V1
  • V2
  • W1
  • W2 

When using the built-in sorting these are sorted as; V1, W1, V2, W2.

But here in Sweden the characters 'V' and 'W' are treated as separate characters.

So I would like these to be sorted as; V1, V2, W1, W2.

 

Is there some kind of setting I can use to resolve this or do I need to implement some kind of custom sorting?

 

Kind regards,

Fredrik

 

4 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 21 Dec 2017, 03:33 PM
Hello Fredrik,

By default, the strings V1, W1, V2, W2 should be sorted as V1, V2, W1, W2. This can be observed in the sample project I've attached to my reply.

Nonetheless, if you wish to change this default order, you can implement custom sorting as suggested in this article.

Please let me know if you require any assistance in the process.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Fredrik
Top achievements
Rank 1
answered on 22 Dec 2017, 01:23 PM

Hello Dilyan!

Thanks for the fast reply.

Do you know if there is a setting in Windows that governs this?

I have tested this on two machines with the same regional settings and it works on one machine, but not the other;

https://www.screencast.com/t/h06zvc0sq8qt

 

Kind regards,

Fredrik

 

0
Accepted
Dilyan Traykov
Telerik team
answered on 27 Dec 2017, 09:45 AM
Hello Fredrik,

I do not believe there's a Windows setting to override this default behavior, but I believe you should be able to achieve the desired result by switching the culture in the Sorting event to en-US, for example, (or any other culture where the sorting is applied as expected) and then switch it back in the Sorted event. Here's what I have in mind:

private CultureInfo currentCulture;
 
public MainWindow()
{
    InitializeComponent();
    this.grid.Sorting += Grid_Sorting;
    this.grid.Sorted += Grid_Sorted;
}
 
private void Grid_Sorted(object sender, GridViewSortedEventArgs e)
{
    Thread.CurrentThread.CurrentCulture = this.currentCulture;
}
 
private void Grid_Sorting(object sender, GridViewSortingEventArgs e)
{
    this.currentCulture = Thread.CurrentThread.CurrentCulture;
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}

Please let me know whether this would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Fredrik
Top achievements
Rank 1
answered on 08 Jan 2018, 12:36 PM

Hello Dilyan,

 

Sorry for  the late reply.

Your solution works as it should.

Apparently Microsoft has decided to change the Finnish/Swedish sorting. So this has nothing to do with the RadGridView component.

 

https://msdn.microsoft.com/en-us/library/cc194877.aspx

 

Kind regards,

Fredrik

Tags
GridView
Asked by
Fredrik
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Fredrik
Top achievements
Rank 1
Share this question
or