Kendo grid post and delete send null to controller

asp.net-web-api, kendo-grid, kendo-ui

Solution

I'd figured it out, although I had to depart from the example http://demos.kendoui.com/web/grid/editing-popup.html

The fix was add the content type, correctly use dataType: "json" as noted above, change from batch: true to batch: false and change the parameter map to the below

 destroy: {
                                    url: crudServiceBaseUrl,
                                    type: "Delete",
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json"
                                },



parameterMap: function (model, operation) {
                                    if (operation !== "read" && model) {
                                        return  kendo.stringify(model) ;
                                    }
                                }

Problem

I'm posting a kendoui web grid and it isn't sending data and I can't see what I'm doing different from the sample that's failing. I'm posting to the controller, but it's either empty (if batch: true or null if batch: false) ``` var crudServiceBaseUrl = "api/Certifications/", dataSource = new kendo.data.DataSource({ transport: { read: { url: crudServiceBaseUrl + member.id, dataType: "json" }, update: { url: crudServiceBaseUrl, type: "Post", dataType: "json" }, destroy: { url: crudServiceBaseUrl, type: "Delete", contentType: "application/json; charset=utf-8", dataType: "json" }, create: { url: crudServiceBaseUrl, type: "Post", dataType: "json" }, parameterMap: function (options, operation) { if (operation !== "read" && options.models) { return {models: kendo.stringify(options.models)}; } } }, editable: { //disables the deletion functionality update: true, destroy: true }, batch: true, pageSize: 30, schema: { model: { id: "Id", fields: { Id: { editable: false, nullable: true }, MemberId: { editable: false, nullable: true }, Name: { validation: { required: true} }, AuthorityName: { validation: { required: true} }, StartDate: { type: "date", validation: { required: true} }, EndDate: { type: "date" } } } } }); $("#certifications").kendoGrid({ dataSource: dataSource, pageable: true, height: 300, toolbar: ["create"], columns: [ { field: "Name", title: "Product Name", width: 250 }, { field: "AuthorityName", title: "Authority", format: "{0:c}", width: "140px" }, { field: "StartDate", title: "Earned", template: '#= kendo.toString(StartDate,"MM/dd/yyyy") #', width: 50 }, { field: "EndDate", title: "Expired", template: '#= kendo.toString(EndDate,"MM/dd/yyyy") #', width: 50 }, { command: ["edit", "destroy"], title: " ", width: "130px" }], editable: "popup" }); ``` the web api: ``` public Certification DeleteCertification(CertificationVm cert) { var model = Uow.Certifications.Get(cert.Id); if (model == null) throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NoContent)); Uow.Certifications.Delete(model); Uow.Commit(); return model; } ```

Original source

Related problems