Hi,
I'm having this problem that only happens in a particular situation. If I have a grid with only one row and I try to delete it, there is a javascript error here.
0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'closest': object is null or undefined
When there is more than one row on the grid, deletes work perfectly fine. I believe it might have to do with the grid trying to set focus to the closest row available...when there are no rows available at all. This is what I'm using to generate the grid. Thanks in advance.
I'm having this problem that only happens in a particular situation. If I have a grid with only one row and I try to delete it, there is a javascript error here.
l._current.closest("table")[0].focus()
Unhandled exception at line 16, column 31418 in http://localhost/zzz/Scripts/kendo/2012.3.1114/kendo.web.min.js0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'closest': object is null or undefined
When there is more than one row on the grid, deletes work perfectly fine. I believe it might have to do with the grid trying to set focus to the closest row available...when there are no rows available at all. This is what I'm using to generate the grid. Thanks in advance.
@(Html.Kendo().Grid<MyNamespace.MyModel>() .Name("myGrid") .Columns(columns => { columns.Bound(c => c.Name); columns.Command(c => {
c.Edit();
c.Destroy(); }); }) .ToolBar(toolbar => { toolbar.Create(); }) .Sortable() .Selectable() .Reorderable(r => r.Columns(true)) .Resizable(r => r.Columns(true)) .Navigatable() .Filterable() .Scrollable(scroll => scroll.Height(500)) .Editable(editable => editable.Mode(GridEditMode.InLine)) .DataSource(dataSource => dataSource .Ajax() .Read(read => read .Type(HttpVerbs.Get) .Url(Url.RouteUrl("DefaultApi", new { httproute = "", controller = "mycontroller" })) ) .Create(create => create .Type(HttpVerbs.Post) .Url(Url.RouteUrl("DefaultApi", new { httproute = "", controller = "mycontroller" })) ) .Update(update => update .Type(HttpVerbs.Put) .Url(Url.RouteUrl("DefaultApi", new { httproute = "", controller = "mycontroller" })) ) .Destroy(destroy => destroy .Type(HttpVerbs.Delete) .Url(Url.RouteUrl("DefaultApi", new { httproute = "", controller = "mycontroller" })) ) .Model(m => { m.Id(c => c.Id); } ) .ServerOperation(false)) )
UPDATE: Since it was apparently just trying to find a row to focus, I added a check to see if the object was null. I wrapped
the call like this.
function(){if(l._current)l._current.closest("table")[0].focus();}
Seems to be working now for both a single row on the grid or multiple rows. Hope this gets fixed in a future release.