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

Filter Date

I''ve been looking at your FilterBar sample, but I haven''t figured out how you filter portions of dates. Here is my problem. My grid has a column whose type is DateTime. The format of the cell is set to "dd-MMM-yyyy". Is there a way to highlight the month portion of the date on the grid, and filter it based on that? For example, if the current cell is "6-Sep-04", how do I filter all the data so that only "Sep" rows are shown? I want to set the RowFilter property of the current dataview to do this. The date format shown on the grid is different than the date format of the actual data. Is there a way to filter the data as shown on the grid?

3 Replies

AD Administrator Syncfusion Team September 6, 2005 07:22 PM UTC

The GridDataBoundGrid uses a DataView.RowFilter property to handling the filtering that requires #''s around dates. Here is a forum thread that discusses this. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=29956


KP Keyur Patel September 6, 2005 07:45 PM UTC

OK, but that doesn''t solve my problem. But it does put me on the right track. When I run your FilterBarGrid sample, and choose the "Orders" table, the "OrderDate" column shows up like this: 1996-07-04T00:00:00.0000000-04:00 But, when I click on the cell, it changes to this: 7/3/1996 How do you get this effect?


AD Administrator Syncfusion Team September 6, 2005 10:33 PM UTC

There is code that tries to specify a date format in that table. gbcc["OrderDate"].StyleInfo.Format = "d"; gbcc["OrderDate"].StyleInfo.CellValueType = typeof(DateTime); But this formatting is not taking because the DataType of the DataColumn in the XML data is System.String which means the grid cannot treat the column as a DataTime column. Instead, it is just the string being displayed that is stored in teh XML data that is used to populate the DataTable in that example. If you have a DataTable with a DataColumn whose DataType is a DateTime type, then the above code should affect its display. Here is a little sample with the proper DateTime column. http://www.syncfusion.com/Support/user/uploads/GDBG_Filter_bad0ab58.zip

Loader.
Live Chat Icon For mobile
Up arrow icon