tomg101
tomg101

Reputation: 169

Kendo Grid Inline Editing Date Format Issue

I have been researching this for days without much luck. I've gone down multiple paths but can't seem to find a solution that works. Any help would be greatly appreciated.

I have a Kendo MVC Grid wired up for CRUD

@(Html.Kendo().Grid<Games.Models.Game>()    
.Name("Grid")    
.Columns(columns => {        
    columns.Bound(p => p.GameName).Width(100);
    columns.Bound(p => p.Publisher).Width(75);
    columns.Bound(p => p.MaxPlayers).Width(75);
    columns.Bound(p => p.DateAdded).Width(100).Format("{0:MM/dd/yyyy}");

When I try and edit the DateAdded field, it changes the date from my nicely formatted date of 05/01/2003 to Thu May 1 17:00:00 CDT 2003 and throws an error when you try to update the data (any data I enter is converted to the Day, Month, Time, TimeZone year format).

The grid throws a "The field DateAdded must be a date error".

I've tried using an Editor Template using the Kendo Date Picker, but the data is not updating into my model.

columns.Bound(p => p.DateAdded).Width(100).Format("{0:MM/dd/yyyy}").EditorTemplateName("DateTime");

Editor Template:

@(Html.Kendo().DatePicker()
                .Name("datepicker")
                .Format("M/d/yyyy")
)

Any idea as to what I am doing wrong? I can skip using the date picker if I can update the date inline, but I can't get either method to work.

Upvotes: 4

Views: 10421

Answers (1)

Petur Subev
Petur Subev

Reputation: 20193

The datetime is validated against the culture specified on the client (the kendo culture). Keep in mind that validation and format of the editor are two different things. You should change the culture to one which Date/Month order is the one you use as format. Similar case here.

More information about the kendo culture and how to change it can be found in the documentation.

Upvotes: 1

Related Questions