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.
Unfortunately, activation email could not send to your email. Please try again.

Group by date in ggc

Thread ID:

Created:

Updated:

Platform:

Replies:

37301 Nov 18,2005 02:04 PM Nov 29,2005 12:55 PM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 18, 2005 02:04 PM

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

Administrator [Syncfusion]
Replied On November 18, 2005 06:31 PM

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

Administrator [Syncfusion]
Replied On November 28, 2005 05:37 PM

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

Administrator [Syncfusion]
Replied On November 28, 2005 06:38 PM

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");
		}
	}
}

Administrator [Syncfusion]
Replied On November 29, 2005 12:55 PM

Thanks Clay, This works. Regards, Esmeralda

CONFIRMATION

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.

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.

;