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

Sorting Date field in GDBG

I have a field in the GDBG that comes in as a date (dd mmm yyyy) without hyphens. When I click the header column tab to sort, the date is treated as a string and sorted. How can I actually sort by date. Thanks, Atith

7 Replies

AD Administrator Syncfusion Team September 1, 2005 11:50 AM UTC

The GridDataBoundGrid really does not do any sorting. It delegates the sorting to the IBindingList datasource. So, if you are using a DataTable as the grid''s datasource, it is the dataTable.DefaultView that is doing the sorting. So, if you are seeing the dates being sorted like strings, it suggests that the type of this DataColumn in the DataTable is a string object and not a DateTime object. If this is the case, the simplest way to handle the problem would be to store the value as a DataTime and set GridBoundColumn.StyleInfo.Format to tell the grid to display the DateTime value with a particular format. If this is not possible, then you would have to do some work to work around the string type being set in the datasource. Here is a forum thread that discusses a couple of ways to do this and has sample information. But changing the DataColumn type will be the simplest solution.


AD Administrator Syncfusion Team September 2, 2005 03:49 PM UTC

Could you please give the link to the discussion thread you mentioned above. Thanks, Bits.


AD Administrator Syncfusion Team September 2, 2005 03:56 PM UTC

Sorry. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=21940


AP Atith Pagdi September 5, 2005 10:33 AM UTC

Clay, I''m getting this date field from the DB, but the GDBG shows it in the format mm/dd/yyyy while I want the format dd-mmm-yyyy. How can I achieve this? Thanks.


AD Administrator Syncfusion Team September 5, 2005 10:51 AM UTC

You set the GridBoundColumn.StyleInfo.Format to specify the format you want to see, and you make sure GridBoundColumn.StyleInfo.CellValueType is being set to typeof(DateTime). It should be if the column in your datatable is DateTime.


AP Atith Pagdi September 5, 2005 10:53 AM UTC

Any code sample for this? I do not have grid bound columns.


AD Administrator Syncfusion Team September 5, 2005 11:35 AM UTC

grid.Binder.InternalColumns["someColumnName"].StyleInfo.Format = "yyyy-MM-dd"; See this KB. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=85

Loader.
Live Chat Icon For mobile
Up arrow icon