GroupDescriptor custom DataFormatString

3 posts, 1 answers
  1. Fernan
    Fernan avatar
    15 posts
    Member since:
    May 2010

    Posted 26 Feb Link to this post

    Hi,

    I have a GridView for a DesktopAlert. It is like the example in your demos. 

    For the grouping by email received datetime I have used the same example: 

     

    var dateGroupDescriptor = new Telerik.Windows.Data.GroupDescriptor<Message, DateTime, DateTime>();
     
               dateGroupDescriptor.GroupingExpression = email => email.Received.Value.Date;
               this.gridView.GroupDescriptors.Add(dateGroupDescriptor);
     
               var dateSortDescriptor = new SortDescriptor<Message, DateTime>();
               dateSortDescriptor.SortingExpression = item => item.Received.Value;
               dateSortDescriptor.SortDirection = System.ComponentModel.ListSortDirection.Descending;
               this.gridView.SortDescriptors.Add(dateSortDescriptor);

     

    It works succesfull, however the format of the group header is "mm/dd/yyyy" and I need other date formart. 

    How do I change the date format string?

     

    Thanks!

  2. Answer
    Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    281 posts

    Posted 29 Feb Link to this post

    Hello,

    The FormatString of the group can be set for the column you are performing the group on. You can use the GroupHeaderFormatString property of the column:

    this.clubsGrid.Columns["Established"].GroupHeaderFormatString = "dd-MM-yyyy";

    GroupDescriptor gd = new GroupDescriptor()
    {
    Member = "Established",
            SortDirection = ListSortDirection.Descending
    }

    this.clubsGrid.GroupDescriptors.Add(gd);

    When performing grouping operation over the "Established" column, the aforementioned format string will be applied for the Group Header. Would it be possible to set the Grouping this way? I have also attached a sample project which you can check.

    Regards,
    Stefan Nenchev
    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. Fernan
    Fernan avatar
    15 posts
    Member since:
    May 2010

    Posted 29 Feb in reply to Stefan Nenchev Link to this post

    Thanks! It works for me
Back to Top