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

GroupDescriptor custom DataFormatString

2 Answers 287 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fernan
Top achievements
Rank 1
Fernan asked on 26 Feb 2016, 11:46 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Stefan Nenchev
Telerik team
answered on 29 Feb 2016, 02:12 PM
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
0
Fernan
Top achievements
Rank 1
answered on 29 Feb 2016, 03:50 PM
Thanks! It works for me
Tags
GridView
Asked by
Fernan
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Fernan
Top achievements
Rank 1
Share this question
or