Kendo Gantt (MVC) is parsing dates on US calendar

2019-08-03 01:19发布

问题:

I'm in the UK and am using a Kendo MVC Gantt chart as follows:

  @(Html.Kendo().Gantt(Of IMS2_App.JobTasksVM, IMS2_App.Models.Dependency)().Name("gantt") _
.Columns(Sub(columns)
                 columns.Bound("id").Title("id").Width(20)
                 columns.Bound("title").Title("Task").Width(200).Editable(False)
                 columns.Bound("start").Title("Start Date").Format("{0:dd MMM yyyy}").Width(90).Editable(True)
                 columns.Bound("end").Title("End Date").Format("{0:dd MMM yyyy}").Width(90).Editable(True)
         End Sub) _
    .Views(Sub(views)
                   views.DayView()
                   views.WeekView(Function(yearView) yearView.Selected(True))
                   views.MonthView()
                   views.YearView()
           End Sub) _
  .DataSource(Function(d) d.Read(Function(read) read.Action("ReadTasks", "Job", New With {.id = Model})).Model(Sub(m)
                                                                                                                       m.Id(Function(f) f.id)
                                                                                                                       m.ParentId(Function(f) f.ParentID)
                                                                                                                       m.OrderId(Function(f) f.OrderID)
                                                                                                                       m.Field(Function(f) f.Expanded)
                                                                                                               End Sub).Update(Function(u) u.Action("UpdateTask", "Job")) )) 

All is working fine until I attempt to update the database via the AJAX post. My datepickers are correctly working in a UK-centric way based on the underlying data, however when posting updates the dates seem to be validated against US calendar (ie MM/dd/YYYY) and the dates are returned under a US interpretation.

I see this issue has been noted for the DatePicker widget here but I don't know how to fix this issue in the Gantt HTML Helper.

Any ideas?

回答1:

I put this issue to Telerik support and they referred me to http://docs.telerik.com/kendo-ui/aspnet-mvc/globalization. My crucial omission was the following in the _Layout.vbhtml:

<script>
    kendo.culture("en-GB");
</script>

Once included (together with the appropriate culture file in my JS bundle) the problem was solved.