Grid column DateTime filter format

1 Answer 9703 Views
Grid
Shawn
Top achievements
Rank 1
Shawn asked on 31 Jul 2017, 03:42 PM

The filter for a DateTime column of an ASP.NET MVC grid is in the US format of MM/DD/YYYY HH:MM.  I would like the date to be shown in the UK format of DD/MM/YYYY.  I have seen similar requests, but these are from 2013.

Are there any newer approaches to getting the filter to show the date format as DD/MM/YYYY?

Regards,

Shawn

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 02 Aug 2017, 01:22 PM
Hello Shawn,

A possible solution is to set the client culture to English culture. The following article illustrates how to change the client culture step by step:


Another solution is to set date format by customizing the filter widget. There are two approaches depending on the mode of the filtering.
 
1. For filter in mode row, the column should be configured as follows:

columns.Bound(x => x.Birthday).Format("{0: MM/dd/yyyy}").Filterable(x => x.Cell(y => y.Template("datePicker")));

And the DatePicker function that builds the customized filter widget should look like the function below:

function datePicker(args) {
 
    args.element.kendoDatePicker({
        format:"dd/MM/yyyy"
    });
 
}

2. When using a filter in mode menu, the column should be configured as follows:

columns.Bound(x => x.Birthday).Format("{0: MM/dd/yyyy}").Filterable(x => x.UI("datePicker"));

The following code block contains the DatePicker function:

function datePicker(element) {
 
       element.kendoDatePicker({
            format:"dd/MM/yyyy"
        });
 
    }


Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Shawn
Top achievements
Rank 1
commented on 02 Aug 2017, 02:12 PM

Georgi,

The filter in mode menu option worked for me. Thank you once again for the help.

Regards,

Shawn

Visvak Prasanth
Top achievements
Rank 1
Veteran
commented on 18 May 2020, 09:22 AM

Hi Georgi,

I tried filter in mode row, when i tried to filter by date no data is returned.

 

Georgi
Telerik team
commented on 20 May 2020, 06:54 AM

Hi Visvak,

Have in mind that if you use the equals operator, also the time portion should match. Could you please test with some other operator for example after?

Regards,
Georgi
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Visvak Prasanth
Top achievements
Rank 1
Veteran
commented on 26 Aug 2020, 05:47 PM

Hi Team,

How to set the default operator for datepicker filter.

For text box i tried b.Filterable(f => f.Enabled(enable).Cell(c => c.Operator("contains").SuggestionOperator(FilterType.Contains))); - this works for textbox.

 

For datepicker i tried b.Filterable(f => f.Enabled(enable).Cell(c => { c.Template("datePickerFilter").Operator("equals"); })) - this does not work; 

the default operator must be equal. if i select the equal manually the date filter works .

Please let me know how to set the default operator for datepicker.

I have attached the screenshot . please refer it .

Thank you in Advance.

 

Georgi
Telerik team
commented on 28 Aug 2020, 11:38 AM

Hello Visvak,

You should simply replace "equals" with "eq".

e.g.

b.Filterable(f => f.Enabled(enable).Cell(c => { c.Template("datePickerFilter").Operator("eq"); }))

Regards,
Georgi
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Visvak Prasanth
Top achievements
Rank 1
Veteran
commented on 28 Aug 2020, 11:56 AM

Hi Georgi,

I tried that also but it did not work. if i change to "eq" getting string error , it is considering the date must be a string.

Visvak Prasanth
Top achievements
Rank 1
Veteran
commented on 28 Aug 2020, 12:22 PM

Hi Georgi,

I have attached  the error screen shot . 

 

Georgi
Telerik team
commented on 01 Sep 2020, 07:54 AM

Hello Visvak,

I have tested the same and it seems to work correctly on my end.

Configuration:

 columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}").Filterable(f => f.Cell(c => { c.Operator("neq"); }));

Operators drop down:

Does the error occur during compilation or upon filter? Would it be possible to share a sample with me where the issue can be replicated?

Regards,
Georgi
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Grid
Asked by
Shawn
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or