Localization of Calendar in Filter of Date Column

6 posts, 0 answers
  1. Peter
    Peter avatar
    35 posts
    Member since:
    May 2016

    Posted 25 May Link to this post

    Hi,

    I have set a grid as  .Filterable(). The Filter dialogs of the columns are localized (german). In a date columnI can use a calender to set a data for filtering. But the calendar is shown in english. It is possible to show it in the language of the grid?

     

    Peter

     

  2. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 27 May Link to this post

    Hi Peter,

    First, please make sure to review the following articles about localization and globalization with MVC Kendo wrappers:
    http://docs.telerik.com/kendo-ui/framework/localization/overview
    http://docs.telerik.com/kendo-ui/aspnet-mvc/globalization

    You can also use $(document).ready or grid dataBound event to access the generated picker controls and apply custom culture options and formatting patterns using Kendo Globalization:
    http://demos.telerik.com/kendo-ui/globalization/index

    Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Peter
    Peter avatar
    35 posts
    Member since:
    May 2016

    Posted 27 May in reply to Eyup Link to this post

     Thanks,

    it would be very helpfull if in http://docs.telerik.com/kendo-ui/aspnet-mvc/globalization the files are named in which the code sould be added or changed

    But now it works for me with
    Step 1 Copy
    Step 2+3 Include the bold lines in _Layout.cshtml
        <script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
        <script src="@Url.Content("~/Scripts/cultures/kendo.culture.de-DE.min.js")"></script>
        <script>  kendo.culture("de-DE");    </script>
    </head>

    That was it.

    But the code

    protected override void Initialize(System.Web.Routing.RequestContext requestContext)
      {
          Thread.CurrentThread.CurrentCulture =
              Thread.CurrentThread.CurrentUICulture =
                  new CultureInfo(requestContext.HttpContext.Request["my-culture"]);
    
          base.Initialize(requestContext);
      }

    not work.

    But the format for the date column will not changed from US to DE.
    So I added in Index.cshtml a Format method. But it will format in US and has no culture argument.
    My workaround:
    @(Html.Kendo().Grid<Data.myView>()
          .Name("grid")
          .Columns(columns =>
          {
              string shortDatePattern = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern;
              columns.Bound(c => c.Date)
                .Format("{0:"+ shortDatePattern + "}")
                .Title("Datum");

    I assume, the code run on the server? So CurrentThread.CurrentUICulture is from the server?

     

    Peter

     

    requestContext.HttpContext.Request["my-culture"]

    get always null.

     

    Peter

     

     

     

  5. Peter
    Peter avatar
    35 posts
    Member since:
    May 2016

    Posted 27 May Link to this post

    Thanks,

    it would be very helpfull if in http://docs.telerik.com/kendo-ui/aspnet-mvc/globalization the files are named in which the code sould be added or changed

    But now it works for me with
    Step 1 Copy
    Step 2+3 Include the bold lines in _Layout.cshtml
        <script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
        <script src="@Url.Content("~/Scripts/cultures/kendo.culture.de-DE.min.js")"></script>
        <script>  kendo.culture("de-DE");    </script>
    </head>

    That was it.

    But the code

    protected override void Initialize(System.Web.Routing.RequestContext requestContext)
      {
          Thread.CurrentThread.CurrentCulture =
              Thread.CurrentThread.CurrentUICulture =
                  new CultureInfo(requestContext.HttpContext.Request["my-culture"]);
    
          base.Initialize(requestContext);
      }

    not work.

    requestContext.HttpContext.Request["my-culture"]

    get always null.

     

    But the format for the Date column will not changed from US to DE.
    So I added in Index.cshtml a Format method. But it will format in US and has no culture argument.
    My workaround:
    @(Html.Kendo().Grid<Data.myView>()
          .Name("grid")
          .Columns(columns =>
          {
              string shortDatePattern = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern;
              columns.Bound(c => c.Date)
                .Format("{0:"+ shortDatePattern + "}")
                .Title("Datum");

    I assume, the code run on the server? So CurrentThread.CurrentUICulture is from the server?

     

    Peter

  6. Peter
    Peter avatar
    35 posts
    Member since:
    May 2016

    Posted 27 May in reply to Peter Link to this post

    please delete the first answer. There is no preview button before posting and I can not delete or edit a post.

    So I posted it corrected again.

  7. Peter
    Peter avatar
    35 posts
    Member since:
    May 2016

    Posted 27 May Link to this post

    if I activate in the Project Configuration Wizard the checkbox: "Copy Global Resources" the culture folder is in the project but i ~\Scripts\kendo\2016.2.504\cultures\

    And I changed the line in _Layout.cshtml to:

       <script src="@Url.Content("~/Scripts/kendo/2016.2.504/cultures/kendo.culture.de-DE.min.js")"></script>

    If I use CDN Support the line should be:

       <script src="@Url.Content("https://kendo.cdn.telerik.com/2016.2.504/js/cultures/kendo.culture.de-DE.min.js")"></script>

Back to Top
UI for ASP.NET MVC is VS 2017 Ready