I was trying to get DatePickerFor work on a Kendo Grid Popup editor with no luck. I've already spent countless hours first with the DropDownListFor (https://www.telerik.com/forums/dropdownlistfor-events-in-razor-pages) which still doesn't work and now with DatePickerFor. Any help is much appreciated.
I have the DatePickerFor in a Kendo Grid Popup Template.
Grid:
.DataSource(dataSource => dataSource
.Custom()
.Transport(t => {
t.Read(r => r.Action("Cases", "CaseList", new { handler = "GetCases" }).Type(HttpVerbs.Post).Data("sendAntiForgeryToken"));
t.Create(r => r.Action("Cases", "CaseList", new { handler = "AddCase" }).Type(HttpVerbs.Post).Data("sendAntiForgeryToken"));
})
Razor Page:
public JsonResult OnPostAddCase([DataSourceRequest] DataSourceRequest request, CaseModel newCase){
if(ModelState.IsValid)
{
}
}
Popup Template:
@(Html.Kendo().DatePickerFor(model => model.LetterDate)
.HtmlAttributes(new { style = "width:150px; font-size:14px" })
)
Model:
[DataType(DataType.Date, ErrorMessage ="Letter Date is required")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
[Display(Name ="LetterDate")]
public DateTime LetterDate { get; set; }
FormData:
LetterDate: Tue Jul 31 2018 13:04:15 GMT-0400 (Eastern Daylight Time)
Error: The value 'Tue Jul 31 2018 13:04:15 GMT-0400 (Eastern Daylight Time)' is not valid for LetterDate.
I have tried several solutions like setting up the culture, changing the formats but nothing seems to work.
The only option that I'm left with is intercepting the date before submit. But before I do that I would like to know why it is so hard to get the basic functionality work with kendo controls. This is so frustrating.