Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc kendoui网格仅使用创建(无删除或更新)_Asp.net Mvc_Grid_Kendo Ui - Fatal编程技术网

Asp.net mvc kendoui网格仅使用创建(无删除或更新)

Asp.net mvc kendoui网格仅使用创建(无删除或更新),asp.net-mvc,grid,kendo-ui,Asp.net Mvc,Grid,Kendo Ui,网格有3行。单击“编辑”时,我会更改“说明”列。然后我单击更新,网格caals将“创建”传输配置。我将batch设置为false,奇怪的是,有3个create代替了更改的行 网格编辑导致创建而不是更新的原因是什么?如果您的记录没有正确设置Id字段,则可能会发生这种情况。数据源认为所有没有id的记录都是“新的”。从未使用剑道网格的此功能。我想知道它是否与HTTP POST/PUT请求相关?我不确定如何在javascript中实现,但您需要使用MVC帮助程序。DataSource(DataSourc

网格有3行。单击“编辑”时,我会更改“说明”列。然后我单击更新,网格caals将“创建”传输配置。我将batch设置为false,奇怪的是,有3个create代替了更改的行


网格编辑导致创建而不是更新的原因是什么?

如果您的记录没有正确设置
Id
字段,则可能会发生这种情况。数据源认为所有没有id的记录都是“新的”。

从未使用剑道网格的此功能。我想知道它是否与HTTP POST/PUT请求相关?我不确定如何在javascript中实现,但您需要使用MVC帮助程序。DataSource(DataSource=>DataSource.Model(Model=>{Model.Id(p=>p.);架构中指定了Id。但是我不确定现有数据记录是否设置了该Id字段。请从“read”设置检查服务器响应。在我的例子中,我已经定义了Model.Id,但是在网格列上没有定义的模型项上。
$("#grid").kendoGrid({
            dataSource: {
                transport: {
                    read: function(options) {
                        $.ajax( {
                            url: "/api/mygetfunction",
                            data: options.data,
                            success: function(result) {
                                options.success(result);
                            }
                        });
                    },
                    update: function (options) {
                        $.ajax({
                            url: "/api/myupdatefunction",
                            data: options.data,
                            success: function (result) {
                                options.success(result);
                            }
                        });
                    },
                    destroy: function (options) {
                        $.ajax({
                            url: "/api/mydestroyfunction",
                            data: options.data, 
                            success: function (result) {
                                options.success(result);
                            }
                        });
                    },
                    create: function (options) {
                        $.ajax({
                            url: "/api/mycreatefunction",
                            type: 'POST',
                            data: ...
                        });
                    },
                    parameterMap: function (options, operation) {
                        if (operation !== "read") {
                            return JSON.stringify(options);
                        }
                    }
                },
                schema: {
                    id: "Id",
                    model: {
                        fields: {
                            Id: { type: "string" },
                            Description: { type: "string" }
                        }
                    }
                },
                pageSize: 10,
                serverPaging: false,
                serverFiltering: false,
                serverSorting: false,
                batch: false
            },
            toolbar: ["create"],
            filterable: true,
            sortable: true,
            pageable: true,
            columns: [
                 {
                    field: "Description",
                    title: "Description"
                 },
                 { command: ["edit", "destroy"], title: " ", width: "210px" }
            ],
            editable: "inline"
        });