string to Date DataColumn sorting

4 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 24 Nov 2014 Link to this post

    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
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Nov 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 28 Jan 2015 in reply to Dimitrina Link to this post

    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

  5. Nick
    Admin
    Nick avatar
    593 posts

    Posted 28 Jan 2015 Link to this post

    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.

     
Back to Top