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

How do I filter a DateTime column on just the date portion

6 Answers 195 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paul Mackenzie
Top achievements
Rank 1
Paul Mackenzie asked on 21 Jun 2010, 07:16 AM
I have a column bound to a DateTime property with a DataFormatString="{}{0:dd-MMM-yyy}".

However when I show the filter for this column, I will see the same date repeating multiple times. When I select one of these repeated dates to filter by, only one record will be displayed.

Is there a way to make the filter to only display the distinct dates shown in the grid and have the filter applied correctly?

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Jun 2010, 07:46 AM
Hi,

 Looks like you have multiple DateTime objects with differences in the time part only. If you want you can create your own custom filter control to handle your scenario similar to this demo.

Sincerely yours,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andreas
Top achievements
Rank 1
answered on 26 Aug 2010, 01:22 PM
Hi!

I'm having the same problem and implemented the custom filter solution that is shown in the Demo.

Now the problem is (...and the same is in the demo):

you have 2 filter options. "From Date" and "To Date".
When you open the filter window  and select a "From Date" --> the filter window closes automatically.
Then you have to open the filter window again and select a "To Date" --> again the filter window closes automatically

So to filter a period between from date and to date you have to open the filter three times
1) open filter and select from date; filter closes
2) open filter and select to date; filter closes
3) opfen filter and press "Filter" button

Is there a way to change this behaviour?
thanks

0
Rossen Hristov
Telerik team
answered on 26 Aug 2010, 03:20 PM
Hello Thomas Roithmeier,

We believe that this was a bug caused by RadDateTimePicker. Can you please upgrade to our latest internal build version and see whether the behavior will be resolved. In case it is not -- drop us a line and we will investigate this further.

By the way, do you know that with our Latest Internal Build we have introduces type-aware filter editors in our default filtering control. So if the type is DateTime you will receive two date-pickers in the filtering control. You can adjust the properties of these RadDateTimePickers by attaching to the FieldFilterEditorCreated of the grid. Inside the event handler you can cast the Editor property of the event arguments to a RadDateTimePicker and then set its input mode -- i.e. date, time or date+time. This might work for you just as well.

I hope this helps.

All the best,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andreas
Top achievements
Rank 1
answered on 31 Aug 2010, 01:24 PM
Hello,

I tried the lastet internal build. The filter works now, but now another bug occured.

When leaving the grid the program dumps with this error.
System.InvalidOperationException was unhandled
  Message='System.Windows.Documents.Hyperlink' is not a Visual or Visual3D.
  Source=PresentationCore
  StackTrace:
       at MS.Internal.Media.VisualTreeUtils.AsVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
       at System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnLostFocus(RoutedEventArgs e) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q2\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Editing.cs:line 348
       at System.Windows.UIElement.IsFocused_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       at System.Windows.DependencyObject.ClearValueCommon(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata)
       at System.Windows.DependencyObject.ClearValue(DependencyPropertyKey key)
       at System.Windows.Input.FocusManager.OnFocusedElementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at System.Windows.FrameworkContentElement.OnGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.ContentElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
       at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
       at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
       at System.Windows.ContentElement.Focus()
       at System.Windows.Documents.Hyperlink.OnMouseLeftButtonDown(Object sender, MouseButtonEventArgs e)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.ContentElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run()
       at Blms2.UserInterface.App.Main() in C:\Users\thomas\Documents\Visual Studio 2010\Projects\LMS\Blms2.UserInterface\obj\x86\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
0
Nedyalko Nikolov
Telerik team
answered on 31 Aug 2010, 03:44 PM
Hi Thomas Roithmeier,

I've managed to simulate the issue. It will be fixed with the next latest internal build (next Friday). Let me know if this is a show-stopper for you, I could send you a private build.
Thank you for your detailed report. I've updated your Telerik points accordingly.

Sincerely yours,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Park
Top achievements
Rank 1
answered on 12 Apr 2011, 10:17 AM
hi admin

my problem is Paul Mackenzie, too.

so, i FromDateToDateFilterControl.xaml modifying..

modify data is From Date: -> 시작일자, To Date: -> 종료일자 (korean data)

it is complie error

Error 4 Cannot resolve reference assemblies. Please check the reference assemblies. Invalid character in the given encoding. Line 18, position 70. D:\Project\일등라이스\IDApp\IDApp\Controls\FromDateToDateFilterControl.xaml IDApp

how can i do?

Tags
GridView
Asked by
Paul Mackenzie
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Andreas
Top achievements
Rank 1
Rossen Hristov
Telerik team
Nedyalko Nikolov
Telerik team
Park
Top achievements
Rank 1
Share this question
or