This is a migrated thread and some comments may be shown as answers.

filtering date time

1 Answer 132 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Avi Avni
Top achievements
Rank 1
Avi Avni asked on 31 Jan 2011, 05:10 PM

Hello

When the Grid View Data Column bound to date time,

If there is string format that show only the time it looks like bug.

We need that the filtering controls display the same date once.

Looks at the attach pictures.

How to resolve this problem?

Best regards

Ehud.

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 02 Feb 2011, 05:12 PM
Hello Ehud Pinchas,

Setting the format string to "short date" doesn't change the data itself but the way it visualizes, so the generated distinct value that may look alike, map to completely different entries in you grid. This is by no means a bug. You may try to change the generated filtering distinct values by handling the DistinctValueLoading event and modifying e.ItemsSource but it might prove rather cumbersome task, because you cannot create a distinct value that maps to multiple entries with different value (i.e. new DateTime(2011, 2, 1)  is different from 02:55:13 01/02/2011 and 11:57:13 01/02/2011 because its hours, minutes and seconds properties are set to their default values). Moreover DateTime is a sealed class and you cannot inherit it and apply your custom logic. If you really want to utilize DateTime of full accuracy (hours, minutes...), I would advise you to create your custom class that contains two DateTime properties that represent same date but with different accuracy. You may use the property with lesser one for filtering and the second one for processing the data. You may refer to the attached project, please.

In addition, you can check this online demo which uses a custom filtering control to filter the date column.

All the best,
Ivan Ivanov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Avi Avni
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or