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

DatePicker not using browser culture

3 Answers 777 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Aleks
Top achievements
Rank 1
Veteran
Aleks asked on 15 May 2020, 07:10 AM

I have a DatePicker configured:-

@(Html
    .Kendo()
    .DatePickerFor(x => x.Date)
    .HtmlAttributes(new { @class = "form-control" })
)

 

 

When running locally, the date format is correct (for me in en-AU).

 

When the same code is published to Azure (running en-US) the date format is incorrect.

If the culture is manually set on the client (using kendo.culture("en-AU")) it doesn't make a difference.

If I force the culture on the server side, it works:-

@(Html
    .Kendo()
    .DatePickerFor(x => x.Date)
    .Culture("en-AU")
    .HtmlAttributes(new { @class = "form-control" })
)

 

 

Why is the DatePicker ignoring the client side culture (both implicit and explicit)?

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 20 May 2020, 06:11 AM

Hi Aleks,

The value of the actual input is generated on the server, thus, it uses the server culture to format it. You will have to set the server culture to en-AU.

I hope this helps.

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.
0
Aleks
Top achievements
Rank 1
Veteran
answered on 27 May 2020, 10:41 PM

Hi Georgi,

Unfortunately, that doesn't really help.

Doesn't this component utilise the Kendo UI for jQuery DatePicker component? if so, why then does it rely on a server-side supplied culture? (the jQuery version doesn't)

Why doesn't it default to the browsers culture, or honour the client side kendo.culture method?

How am I meant to create an application that caters for multiple cultures if I have to know the client's culture on the server side??

0
Georgi
Telerik team
answered on 01 Jun 2020, 12:29 PM

Hello Aleks,

The initial value of the picker is created on the server, thus it is formatted using the server side culture.

Furthermore, you could sync the cultures on client and server by submitting the client culture to the server and then apply it to the server as follows:

var cultureInfo = new CultureInfo("en-US"); // hardcoded culture for the sake of the example

CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

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.
Tags
Date/Time Pickers
Asked by
Aleks
Top achievements
Rank 1
Veteran
Answers by
Georgi
Telerik team
Aleks
Top achievements
Rank 1
Veteran
Share this question
or