0

我们最近下载了 Kendo UI 套件的试用版,以便在试用结束时进行购买。我们在 Ajax 绑定模式下使用 Kendo 网格控件并注意到一些问题。主要问题是删除模型中绑定到网格的最后一条记录时出现以下脚本错误:

http:// * * /Scripts/kendo/2012.3.1114/kendo.web.js 0x800a138f第 18 行第 31059 列未处理的异常- Microsoft JScript 运行时错误:“_current”为空或不是对象

我们无法在 Chrome 中复制它。我们对 Kendo 很感兴趣,因为它被宣传为与 IE8 兼容。情况似乎并非如此。

这是我们的 .cshtml 文件中的网格:

@(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))
      )

这是我们控制器上处理删除的操作:

[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());
}

这是剑道网格的错误还是我们错过了一些明显的东西?只是回顾一下..脚本错误仅在删除网格中的最后一条记录时发生。

4

1 回答 1

0

好的,我刚刚在 Tekerik 论坛上找到了这个:

http://www.kendoui.c​​om/forums/mvc/grid/deleting-only-row-on-grid-generates-a-javascript-error-and-doesn-t-execute-the-call-to-the-服务器.aspx

看起来这是剑道当前发布版本(2012.3.1114)的一个错误。显然它已在最新的内部版本中修复。

于 2013-01-23T10:00:41.493 回答