We have recently downloaded a trial version of the Kendo UI suite with a view to making a purchase at the end of the trial. We are using the Kendo grid control in Ajax binding mode and have noticed a few problems. The main issue is that the following script error occurs when deleting the last record in the model that is bound to the grid:
Unhandled exception at line 18, column 31059 in http://**/Scripts/kendo/2012.3.1114/kendo.web.js 0x800a138f - Microsoft JScript runtime error: '_current' is null or not an object
We cannot replicate this in Chrome. We are interested in Kendo as it is marketed as being compatible with IE8. This doesn't appear to be the case.
Here is the grid in our .cshtml file:
@(Html.Kendo().Grid(Model)
.Name("UserGrid")
.HtmlAttributes(new { style = "height:500px" })
.Columns(columns =>
{
columns.Bound(p => p.ReferenceNumber).Groupable(false);
columns.Bound(p => p.Title).Title("Title");
columns.Bound(p => p.AgreementDate).Title("Agreement Date");
columns.Bound(p => p.Superseded).ClientTemplate(
"<input type='checkbox' disabled='disabled' value='#= Superseded #' " +
"# if (Superseded) { #" +
"checked='checked'" +
"# } #" +
"/>");
//columns.Bound(p => p.Parties.Count);
columns.Bound(p => p.SourceDocumentLink);
columns.Bound(p => p.RelationshipLeadDirector);
columns.Bound(p => p.Owner);
columns.Bound(p => p.LegalContact);
columns.Command(command => command.Destroy()).Width(100);
columns.Template(@<text></text>).ClientTemplate("<a class='k-button k-button-icontext k-edit-button' href='" + Url.Action("Update", "Agreement") + "/#=Id#'><span class='k-icon k-edit'></span>Edit</a>");
})
.DataSource(dataSource => dataSource
.Ajax()
//.Server()
//.Events(events => events.RequestStart("requeststart_handler"))
//.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.Id))
.Destroy("Delete", "Agreement")
.Update("Update","Agreement")
.Read(read => read.Action("ListAgreements", "Agreement")
))
.Navigatable()
.Scrollable()
.Resizable(s=>s.Columns(true))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Sortable()
.Pageable(builder => builder.PageSizes(true))
)
And here is the action on our controller that takes care of a delete:
[HttpAjaxPost]
public JsonResult Delete([DataSourceRequest] DataSourceRequest request, AgreementData agreement)
{
try
{
_agreementService.DeleteAgreement(agreement);
ModelState.Clear();
}
catch (Exception ex)
{
Logger.GetLog(Logger.ServiceLog).Error(ex);
ModelState.AddModelError("errors", "Delete failed");
}
return Json(ModelState.ToDataSourceResult());
}
Is this a bug with the Kendo grid or have we missed something obvious? Just to recap..the script error only occurs when deleting the last record in the grid.