Sorting does not work

6 posts, 0 answers
  1. Sysadmins
    Sysadmins avatar
    4 posts
    Member since:
    Jun 2015

    Posted 03 Sep 2015 Link to this post

    I have problem with sorting on GridView 

    I have two number columns (integers) and when I click on the column header to sort it sorts them as string and not numeric values.

    .xaml file

     <telerik:RadGridView x:Name="gridViewOrders"
                                         ShowGroupPanel="False"
                                         AutoGenerateColumns="False"
                                         CanUserSortColumns="True"
            RowIndicatorVisibility="Collapsed"
                                         IsFilteringAllowed="False">
                                    <telerik:RadGridView.Columns>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Order}"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Account}" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Timestamp}"/>
                                    </telerik:RadGridView.Columns>
       </telerik:RadGridView>​

     

    cs file

     

     gridView​Orders.ItemsSource = tradesRepo.ListOfPendingOrders;​

     

     

    Any ideas?

     

    Thanks

  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 03 Sep 2015 Link to this post

    Hi Panayiotis,

    This is indeed strange. Sorting is a data operation and it is performed by building and executing a LINQ query over the source collection. If the bound property is an integer, RadGridView will sort the column numerically. Please verify that the property from your model is numeric and not string.

    Regards,
    Yoan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Sysadmins
    Sysadmins avatar
    4 posts
    Member since:
    Jun 2015

    Posted 03 Sep 2015 in reply to Yoan Link to this post

    It is indeed.

    My Viewmodel contains 2 Integers (Order, Account), one string (Name) and a DateTime (Timestamp);

    No custom code needed to make sorting work by default right?

     

    Thanks,

  5. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 03 Sep 2015 Link to this post

    Hi Panayiotis,

    Sorting is working out-of-the-box, no custom code is needed. May I ask you to provide a sample project which demonstrates the problem?

    Regards,
    Yoan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Sysadmins
    Sysadmins avatar
    4 posts
    Member since:
    Jun 2015

    Posted 14 Sep 2015 in reply to Yoan Link to this post

    I already posted code above.

     

    tradesRepo.ListOfPendingOrders contains objects as described:

    "My Viewmodel contains 2 Integers (Order, Account), one string (Name) and a DateTime (Timestamp);"​

  7. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 15 Sep 2015 Link to this post

    Hi Panayiotis,

    I have created a sample project based on your description. Sorting is working as expected. Please give it a try and let me know how it works for you.

    Regards,
    Yoan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready