剑道 UI 网格更新按钮未触发

law*_*tog 0 asp.net-mvc kendo-ui kendo-grid

我正在开发一个带有 javascript 内联可编辑选项的 KendoUI 网格,并且无法使更新按钮触发点击事件并将数据发布到服务器端更新事件。单击更新按钮甚至不会更新客户端上的网格。

希望有人能帮我指出我在这里做错了什么。

这不是重复的,因为我已经厌倦了答案中的 jfiddle 链接并且它也不起作用。 剑道 UI 网格更新功能不会触发

<div id="grid"></div>

 @section Scripts{

<script type="text/javascript">

    $(function () {
        var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "Home/GetPupilsAsJson",
                    dataType: 'json'
                },                    
                update: {
                    url: "Home/UpdatePupils",
                    dataType: 'json',
                    type: 'POST'
                }
            },
            pageSize: 5,
            autoSync: true                
        });

        $('#grid').kendoGrid({
            dataSource: dataSource,
            editable: "inline",
            pageable: true,
            columns: [{
                field: "Id",
                title: "Id",
                width: 150,
                hidden: true
            }, {
                field: "Firstname",
                title: "Firstname",
                width: 150
            }, {
                field: "Lastname",
                title: "Lastname",
                width: 150
            }, {
                field: "DateOfBirth",
                title: "DateOfBirth",
                width: 150
            }, {
                field: "Class",
                title: "Class",
                width: 150
            }, {
                field: "Year",
                title: "Year",
                width: 150
            },
            {
                command: ["edit"],
                width: 150
            }]
        });       
    });
</script>    
 }
Run Code Online (Sandbox Code Playgroud)

家庭控制器

 public ActionResult GetPupilsAsJson()
    {            
        return Json(GetPupils(), JsonRequestBehavior.AllowGet);
    }

[AcceptVerbs(HttpVerbs.Post)]
    [HttpPost]
    public void UpdatePupils(Pupil p)
    {
          //never reach here
    }
Run Code Online (Sandbox Code Playgroud)

law*_*tog 5

我不知道为什么,但通过放置架构信息来修复它。

schema: {
        model: {
            id: "Id",
            fields: {
                Firstname: { editable: true, validation: { required: true } },
                Lastname: { validation: { required: true } },
                DateOfBirth: { validation: { required: true } },
                Class: { validation: { required: true } },
                Year: { validation: { required: true } }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)