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

string to Date DataColumn sorting

3 Answers 286 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ITA
Top achievements
Rank 1
ITA asked on 24 Nov 2014, 01:11 PM
Hi,

i bind an ObservableCollection to a RadGridView.

TaskGridView.ItemsSource = ItemColleciotn;

xaml:
<telerik:GridViewDataColumn DataMemberBinding="{Binding Mydate, StringFormat=d}" Width="80" Header="{Binding Source={StaticResource Lang}, XPath=GrudDatumHeader/@Header}" x:Name="Beginnlbl" >

Now i want to sort the GridView

<telerik:RadGridView.SortDescriptors>
       <telerik:SortDescriptor Member="MyDate"  SortDirection="Ascending" />
</telerik:RadGridView.SortDescriptors>

The Problem ist, that the GridViewDataColoumn is a string and the sorting works, but in a wrong way for example:

08.11.2014
09.11.2014
10.10.2014
11.11.2014

The Date 10.10.2014 should be the first one. How can i solve this?

Thanks
Best Regards
rene

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Nov 2014, 07:04 AM
Hello Rene,

You can check some sample code on our Custom Sorting with IComparable WPF Demo. It demonstrates using the IComparable interface. Using a Generic Sort Descriptor is also an option.

You can also refer to the Custom Sorting article in our online documentation.

I hope this helps.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
ITA
Top achievements
Rank 1
answered on 28 Jan 2015, 02:41 PM
Hi,

thanks, but this does not solve the Problem. It's still the same. After sorting i get this

Startdate:

18.01.15
03.02.15
02.02.15

or

02.02.15
03.02.15
18.01.15

The sorting as a string ist ok, but this is a Date?! How do i sort by date?

Thanks
Best Regards
WW

0
Nick
Telerik team
answered on 28 Jan 2015, 03:17 PM
Hello Rene,

The sorting mechanism uses the display values to sort the column. You can set a SortMemberPath to the column to explicitly state that it should be sorted by that property, not the converted value. 

Hope this helps. 

Regards,
Nick
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
ITA
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
ITA
Top achievements
Rank 1
Nick
Telerik team
Share this question
or