We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Group label format

Thread ID:





119344 Jun 8,2015 02:29 PM UTC Jun 10,2015 11:55 AM UTC WinForms 3
Tags: GridGroupingControl
Felipe Bahiana Almeida
Asked On June 8, 2015 02:29 PM UTC

I have one grid that has one datetime column. 
When I try to use this column, to group itens related, this is showing date in format "dd/MM/yyyy hh:mm:ss AM/PM" in the group label.
I want to be able to format these values acording to my users (MMM-yy) and make syncfusion group itens in the same month/year.

(I tried to create one adictional column of type string that contais that value, but the problem is that the sort is messed up.


Attachment: print_186e85ce.zip

Solai A L [Syncfusion]
Replied On June 9, 2015 05:31 AM UTC

Hi Felipe,

Thank you for using Syncfusion products.

To change the value of Caption label after grouping, you can use QueryCellInfo event. In this event you can customize the Caption Row cellvalue as per you requirement. The format for column will be applied only when the cellvaluetype is in corresponding type. Please refer the below image for reference. Also the below code and sample for further clarification. If your requirement is different from this please let us know with a brief explanation.

Code Snippet[c#]:

this.gridGroupingControl1.TableDescriptor.Columns["Date"].Appearance.AnyCell.CellValueType = typeof(DateTime);

this.gridGroupingControl1.TableDescriptor.Columns["Date"].Appearance.AnyCell.Format = "MMM-yyyy";

this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);

  void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)


            if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell && e.TableCellIdentity.GroupedColumn != null)


                GridCaptionRow captionRow = e.TableCellIdentity.DisplayElement as GridCaptionRow;

                string date="";

                DateTime dt;

                if (e.Style.Text != null && DateTime.TryParse(e.Style.Text.Substring(e.Style.Text.IndexOf(":") + 1, 8),out dt))


                    date = dt.ToString("MMM-yyyy");


                e.Style.CellValue = String.Format("{0}: {1} Items.", date, e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount());



Thanks & Regards,

Felipe Bahiana Almeida
Replied On June 9, 2015 12:33 PM UTC

Thanks Solai, your example is good but there is one part missing.
Note that the sort order is wrong. We must see dates in this format but order by the Date values, not by string values.

Solai A L [Syncfusion]
Replied On June 10, 2015 11:55 AM UTC

Hi Felipe,

Sorry for the inconvenience.

By default our grid grouping control support only string sorting. For your case you need to use Custom sorting using IComparer and handle that in SortedColumns.Changing event with the following code.  Please refer the below sample and code snippet for further clarification.

Code Snippet[c#]:

gridGroupingControl1.TableDescriptor.SortedColumns.Changing += new Syncfusion.Collections.ListPropertyChangedEventHandler(SortedColumns_Changing);

void SortedColumns_Changing(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)


            SortColumnDescriptor sd = e.Item as SortColumnDescriptor;

            if (sd != null && e.Action == Syncfusion.Collections.ListPropertyChangedType.Add)


                Type type = this.gridGroupingControl1.TableDescriptor.Columns[sd.Name].Appearance.AnyRecordFieldCell.CellValueType;

                if (sd.Name == "Date" && type == typeof(DateTime))

                    sd.Comparer = new DateComparer();



public class DateComparer : IComparer


        public DateComparer() { }

        public int Compare(object x, object y)


            DateTime value1 = DateTime.Parse(x.ToString());

            DateTime value2 = DateTime.Parse(y.ToString());

            return DateTime.Compare(value1,value2);





Please let us know if you have any other concerns.

Thanks & Regards,



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon