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

How to format a DateTime as text with no dropdown in a GGC (GridGroupingControl)

We have a requirement for a column in a GridGroupingControl to display a full date time in full format "dd/MM/yyyy h:mm:ss tt". Note that this is a read-only grid so we don't need users to be able to edit anything.

By default GGC columns bound to a DateTime display as "dd/MM/yyyy" and have a drop down that displays a date picker control. I've been able to disable the date picker control, and when you actually select a cell it displays as "dd/MM/yyyy h:mm:ss tt", but cells that are not selected are shown in "dd/MM/yyyy" format.

I've tried changing heaps of different properties and googling but can't find the solution. What property or properties need to be set to display full date and time in DateTime columns, rather than just dates?

1 Reply

GM Gowri Manohari D Syncfusion Team November 13, 2009 12:06 PM UTC

Hi Ben,

Thank you for choosing Syncfusion Products.

We have created sample for your requirement. The sample which i have created will display the "DateTime" column with "dd/mm/yyyy h:mm:ss tt" format. All the formatting will be done in GridGroupingControl1_QueryStyleInfo event. Please refer the code snippet for more details

void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell)
{
if(e.TableCellIdentity.Column.Name == "Birthdate" )
{
e.Style.Format = "dd/MM/yyyy h:mm:ss tt";
}
e.Handled = true;
}
}

Please find the sample from below link

http://files.syncfusion.com/support/GGC.Web/7.3.0.20/F91338/main.htm

Let me know if you have any other queries.

Regards,
Gowri

Loader.
Live Chat Icon For mobile
Up arrow icon