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

Localization of Calendar in Filter of Date Column

5 Answers 325 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 25 May 2016, 08:04 AM

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

 

5 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 27 May 2016, 06:49 AM
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
0
Peter
Top achievements
Rank 1
answered on 27 May 2016, 10:20 AM

 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

 

 

 

0
Peter
Top achievements
Rank 1
answered on 27 May 2016, 10:57 AM
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

0
Peter
Top achievements
Rank 1
answered on 27 May 2016, 11:01 AM

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.

0
Peter
Top achievements
Rank 1
answered on 27 May 2016, 12:43 PM

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>

Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Peter
Top achievements
Rank 1
Share this question
or