Kendo UI Grid内联编辑发布的数据为空

我在MVC4中跟踪演示网格内联编辑,但我发现插入/编辑控制器中的发布网格数据为空.

cshtml的代码如下:

@(Html.Kendo().Grid<CRM.Models.M_ProductGroup>()
    .Name("Group")
    .Columns(columns =>
    {
        //columns.Bound(g => g.CompanyNo).Hidden();
        columns.Bound(g => g.CompanyNo).Width(60);
        columns.Bound(g => g.ProductGroupNo).Width(60);
        columns.Bound(g => g.ProductGroupName).Width(120);
        columns.Command(command =>
        {
            command.Custom("SelectProducts");
            command.Edit();
            command.Destroy();
        }).Width(200);
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .ClientDetailTemplateId("groupSetTemplate")
    .Pageable()
    .Sortable()
    .Scrollable()
    //.Resizable(resize => resize.Columns(true))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Events(events => events.Error("error_handler"))
        .Model(model =>
        {
            model.Id(g => g.CompanyNo);
            model.Id(g => g.ProductGroupNo);
            //model.Field(g => g.ProductGroupName);
        })
        .Create(create => create.Action("InsertGroup", "MProductGroup"))
        .Read(read => read.Action("ShowGroup", "MProductGroup"))
        .Update(update => update.Action("ChangeGroup", "MProductGroup"))
        .Destroy(destroy => destroy.Action("DeleteGroup", "MProductGroup"))
    //.PageSize(20)
    )
    //.Events(events => events.DataBound("dataBound"))

控制器代码如下:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult InsertGroup([DataSourceRequest] DataSourceRequest request, M_ProductGroup group)
    {
        if (group != null && ModelState.IsValid)
        {
        return Json(new[] { group }.ToDataSourceResult(request, ModelState));
    }

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult ChangeGroup([DataSourceRequest] DataSourceRequest request, M_ProductGroup group)
    {
        if (group != null && ModelState.IsValid)
        {

        }

        return Json(ModelState.ToDataSourceResult());
    }

发布的数据(“组”)为空,我无法得到它.

最佳答案 检查项目中是否包含kendo.aspnetmvc.min.js.

点赞