Swedish sorting

5 posts, 1 answers
  1. Fredrik
    Fredrik avatar
    8 posts
    Member since:
    Nov 2014

    Posted 19 Dec 2017 Link to this post

    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

     

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    761 posts

    Posted 21 Dec 2017 Link to this post

    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.
  3. Fredrik
    Fredrik avatar
    8 posts
    Member since:
    Nov 2014

    Posted 22 Dec 2017 in reply to Dilyan Traykov Link to this post

    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

     

  4. Answer
    Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    761 posts

    Posted 27 Dec 2017 Link to this post

    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.
  5. Fredrik
    Fredrik avatar
    8 posts
    Member since:
    Nov 2014

    Posted 08 Jan in reply to Dilyan Traykov Link to this post

    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

Back to Top