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. Image for the cookie policy date
close icon

Group by date in ggc

Hi, I have a ggc and trying to group by date. When I drag the column in the drop down area, it groups by date & time. I don''t need the time, but the date only. How can I accomplish this? Thanks, Esmeralda

4 Replies

AD Administrator Syncfusion Team November 18, 2005 11:31 PM UTC

You can add a custom sort comparer. Here is a little sample. http://www.syncfusion.com/Support/user/uploads/GGC_DateGrouping_da6c361b.zip


AD Administrator Syncfusion Team November 28, 2005 10:37 PM UTC

I tried the sample but the child group options caption text "Category" part still includes the time for date-time groups. I want to group by a column named "BirthDate" for example, and having the dates include the time portion is confusing to users. Esmeralda


AD Administrator Syncfusion Team November 28, 2005 11:38 PM UTC

If you are only grouping dates, you can just set this property. this.gridGroupingControl1.ChildGroupOptions.CaptionText = "{CategoryCaption}={Category:MM/dd/yyyy}"; But if you need to support grouping things other than dates, then you cannot just set this property. Instead, you need to handle the QueryCellStyleInfo and conditionally format th ecaption depending upon the caption being provide in QueryCellStyleInfo.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
	if(e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
	{
		GridCaptionRow cap = e.TableCellIdentity.DisplayElement as GridCaptionRow; 
		if(cap.ParentGroup.Category is DateTime)
		{
			e.Style.Text = ((DateTime)cap.ParentGroup.Category).ToString("MM/dd/yyyy");
		}
	}
}


AD Administrator Syncfusion Team November 29, 2005 05:55 PM UTC

Thanks Clay, This works. Regards, Esmeralda

Loader.
Live Chat Icon For mobile
Up arrow icon