Hi,
I'm trying to enable batch editing for a grid bound to an odata data source but having trouble using ParameterMap function to properly format a request.
I started from this example (https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-odata-crud) and my code looks like this:
I've attached a demo project that includes my web service.
Thanks,
Griffin
I'm trying to enable batch editing for a grid bound to an odata data source but having trouble using ParameterMap function to properly format a request.
I started from this example (https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-odata-crud) and my code looks like this:
<html> <head> <meta charset="utf-8" /> <title>OData CRUD</title> <link href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.common.min.css" rel="stylesheet" /> <link href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.default.min.css" rel="stylesheet" /> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script src="http://cdn.kendostatic.com/2012.1.322/js/kendo.all.min.js"></script> </head> <body> <div id="grid"></div> <script> $(document).ready(function () { var crudServiceBaseUrl = "/Northwind.svc/Products", dataSource = new kendo.data.DataSource({ type: "odata", transport: { read: { url: crudServiceBaseUrl, dataType: "json" }, update: { url: function(data) { return crudServiceBaseUrl + "(" + data.ProductID + ")"; } }, create: { url: crudServiceBaseUrl }, destroy: { url: function(data) { return crudServiceBaseUrl + "(" + data.ProductID + ")"; } }, parameterMap: function (data, operation) { if (operation !== "read" && data.models) { //return { items: kendo.stringify(data.models) }; return { data: kendo.stringify(data.models) }; } } }, batch: true, pageSize: 10, serverPaging: true, schema: { data: "d", model: { id: "ProductID", fields: { ProductID: { editable: false, nullable: true }, ProductName: { validation: { required: true } }, UnitPrice: { type: "number", validation: { required: true, min: 1} }, Discontinued: { type: "boolean" }, UnitsInStock: { type: "number", validation: { min: 0, required: true } } } } } }); $("#grid").kendoGrid({ dataSource: dataSource, height: 400, pageable: true, editable: true, toolbar: ["create", "save", "cancel"], columns: [ "ProductName", { field: "UnitPrice", format: "{0:c}", width: "150px" }, { field: "UnitsInStock", width: "150px" }, { field: "Discontinued", width: "100px" }, { command: ["destroy"], title: " ", width: "110px" }] }); }); </script> </body></html>I've attached a demo project that includes my web service.
Thanks,
Griffin