Need an example of how to use a date picker to change the date field in a Keno grid. The examples I can find only show a dropdown. I have not problem get this to work on the client side. But I can not find anything that show how to return the updated value back to the server.
Razor page:
@(Html.Kendo().Grid<Pages.EditContract>()
.Name("grid")
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Columns(columns =>
{
columns.Bound(p => p.StartDate);
columns.Bound(p => p.EndDate).ClientTemplate("#=EndDate#").Sortable(false).Width(180).Format("MM/dd/yyyy");
})
.DataSource(ds => ds.Ajax()
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.StartDate).Editable(false);
model.Field(p => p.EndDate).Editable(true);
})
.Read(r => r.Url("/Edit?handler=Read").Data("forgeryToken"))
.Update(r => r.Url("/Edit?handler=Update").Data("forgeryToken"))
.Model(m => m.Id(id => id.Id))
.PageSize(4)
)
//.Events(ev => ev.DataBound("db"))
)
Edit Template:
@model ContractorManagment.Models.Contract
@(Html.Kendo().DatePicker()
.Name("EndDate") // The name of the DatePicker is mandatory. It specifies the "id" attribute of the widget.
.Format("MM/dd/yyyy")
//.Value(Model.EndDate) // Sets the value of the DatePicker.
)
If it was not in a grid all you have to do is set the .Value property. But that does not work when it is in a grid.
.HtmlAttributes(new { data_bind = "value: EndDate" })
But now I have an issue with the Datepicker ignoring the Format("MM/dd/yyyy") and returning the string "Fri Jun 01 2029 00:00:00 GMT-0500 (Central Daylight Time)" which is not a valid date. Any attempt to format it or convert it to a date return, error not a recognizable date.
Any way for getting the Datepicker recognize the Format parameter for the date it returns?