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

[Solved] Is filtering of DateTime values in DD/MM/YYYY format possible?

3 Answers 332 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.
Marcel
Top achievements
Rank 1
Marcel asked on 25 Jun 2009, 12:37 PM
Hi,

I have a GridView that displays DateTime values in the following datetime format "DD/MM/YYYY" and the cuture is set to "nl-NL".
But when I use filtering and I fill in a filter value for this column in the filter I have to use the MM/DD/YYYY format.

Is there a way that the filter can accept dates in the DD/MM/YYYY format?

Thanks,
Marcel




3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 26 Jun 2009, 01:52 PM
Hello Marcel,

Currently the filter does not respect the string format of the respective column. The only way to make both appear the same way is to use an IValueConverter:

    public class DateToLongDateStringConverter : IValueConverter 
    { 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            DateTime dateTime = (DateTime)value; 
            return dateTime.ToString("dd/MM/yyyy"); 
        } 
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            throw new NotImplementedException(); 
        } 
    } 
 

<UserControl x:Class="Ticket222538_DateTimeFilteringFormat.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"  
    xmlns:local="clr-namespace:Ticket222538_DateTimeFilteringFormat;assembly=Ticket222538_DateTimeFilteringFormat"  
    > 
    <Grid x:Name="LayoutRoot" Background="White"
        <Grid.Resources> 
            <local:DateToLongDateStringConverter x:Key="myConverter" /> 
        </Grid.Resources> 
        <telerikGrid:RadGridView Name="RadGridView1" AutoGenerateColumns="False"
            <telerikGrid:RadGridView.Columns> 
                <telerikGrid:GridViewDataColumn  
                    HeaderText="Date Received"  
                    DataMemberBinding="{Binding Path=Received, Converter={StaticResource myConverter}}"/> 
            </telerikGrid:RadGridView.Columns> 
        </telerikGrid:RadGridView> 
    </Grid> 
</UserControl> 
 

I have attached the sample project that the above code snippets are from. I hope this helps.

All the best,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Justin Brown
Top achievements
Rank 1
answered on 16 Dec 2009, 05:56 AM
This doesn't seem to address the issue.

For example, if I enter a 'dd/mm/yyyy' formatted date such as "30/6/1990", and specify "Is greater than or equal to", the filter still breaks (the grid appears empty - however it works fine if I enter "6/30/1990"). Could you please send me a solution to this problem. What would be really nice is a customised filter dialog using the date selection control for entering the dates... Just while you're at it like.... ;-)

Thanks
Justin
0
Vlad
Telerik team
answered on 16 Dec 2009, 07:35 AM
Hello Justin,

You can check this demo for more info on how to create your own filter controls: http://demos.telerik.com/silverlight/#GridView/CustomFilterControls


Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Marcel
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Justin Brown
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or