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

Sorting does not work

5 Answers 235 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sysadmins
Top achievements
Rank 1
Sysadmins asked on 03 Sep 2015, 09:07 AM

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

5 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 03 Sep 2015, 09:43 AM
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
0
Sysadmins
Top achievements
Rank 1
answered on 03 Sep 2015, 09:50 AM

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,

0
Yoan
Telerik team
answered on 03 Sep 2015, 12:06 PM
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
0
Sysadmins
Top achievements
Rank 1
answered on 14 Sep 2015, 09:20 AM

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);"​

0
Yoan
Telerik team
answered on 15 Sep 2015, 11:00 AM
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
Tags
GridView
Asked by
Sysadmins
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Sysadmins
Top achievements
Rank 1
Share this question
or