DatePicker - french culture, wrong format (16.10.2013 instead of 16/10/2013)

5 posts, 0 answers
  1. Catalin
    Catalin avatar
    18 posts
    Member since:
    Jun 2008

    Posted 16 Oct 2013 Link to this post

    Hi,

    I’m currently testing KendoUI for a future project and I have a little issue with the DatePicker. Let me explain:
    • New KendoUI application with globalization;
    • Add the fr-FR culture: 
    <script src="@Url.Content("~/Scripts/kendo/2013.2.918/cultures/kendo.culture.fr-FR.min.js")"></script>

    • Set the kendo culture in the layout:
       <script type="text/javascript">
           kendo.culture("fr-FR")
       </script>


    • Creating in the Index.cshtml a DatePicker.
    When running the app and select a date, the DatePicker displays (for example) 16.10.2013. This value cannot be validated, the system expects “16/10/2013”. The culture of the calendar is OK (french labels everywhere), but the value which is displayed has a wrong format. 

    Otherwise, If I choose to set the culture of the DatePicker explicitly:

                @(Html.Kendo().DatePickerFor(m=>m.D)
                    .Culture("fr-FR")
                )


    Then everything works like a charm.

    Did I missed something? 

    Thank you,

    Catalin




  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 18 Oct 2013 Link to this post

    Hello Catalin,

    Is the .NET culture set to "fr-FR"? By default the datepicker MVC wrapper uses the current .NET culture to set the format.

    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Catalin
    Catalin avatar
    18 posts
    Member since:
    Jun 2008

    Posted 19 Oct 2013 Link to this post

    Hi Daniel, and thank you for your answer. 

    I don't understand what do you mean by ".NET Culture". 

    Adding 
    @{
        System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR");
    }
     won't fix my problem, unfortunately. 

    So, how can I use the datePicker without explicitly set it's culture every time I use it? Thank your for your help.
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 23 Oct 2013 Link to this post

    Hello again,

    Besides setting the CurrentUICulture(used for the messages), you should also set the CurrentCulture(determines the formats):

    System.Threading.Thread.CurrentThread.CurrentCulture =
        System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR");
    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Catalin
    Catalin avatar
    18 posts
    Member since:
    Jun 2008

    Posted 24 Oct 2013 Link to this post

    Hi, 

    Thank you, Daniel, it works !


Back to Top
Kendo UI is VS 2017 Ready