如何设置 CRUD 在 Kendo 中工作?

How to set CRUD working in Kendo?

如何在Kendo中设置CRUD?更新和读取可以,但不能创建。这是我这部分的代码:

 create: {
          url: function (data) {
            return $("#gatewayPath").data("value") + "odata/ods/ProcessProductionPerformanceMovements";
          },
          dataType: "json",
          type: "POST",
          beforeSend: function (x) {
            var auth = $("#authenticationType").data("value") + " " + $("#authenticationToken").data("value");
            x.setRequestHeader("Authorization", auth);
          }
        },

在 parameterMap 中我有:

if (operation === "create") {
             return '{ "_Key": "' + data._Key +
                '", "Comment": "' + data.Comment +
                '","MovementType": "' + data.MovementType +
                ((data.Unit) ? '","_UnitKey": "' + data.Unit._Key: "") +
                ((data.Material) ? '","_MaterialKey": "' + data.Material._Key: "") +  
                '","MaterialLotID": "' + data.MaterialLotID +
                '","Status": "' + data.Status +
                '","Quantity": "' + data.Quantity  +
                '","Description": "' + data.Description + 
                '","_UnitKey": "' + data._UnitKey + 
                '","_ProdPerfHeaderKey": "' + data._ProdPerfHeaderKey + 
                '","StockType": "' + data.StockType + 
                '","StockIndicator": "' + data.StockIndicator + 
                '","SAPStorageLocation": "' + data.SAPStorageLocation + 
                '"}';
          }

telerik.com 上有一个创建示例。

var dataSource = new kendo.data.DataSource({
    transport: {
        /* the other CRUD settings are ommitted for brevity */
        create: function (e) {
            // batch is disabled
            // generate appropriate data item ID and save the new items to the original datasource
            e.data.my_ID_field_name = 123;
            // ...

            // on success return the new data items with IDs
            e.success(e.data);
            // on failure
            //e.error("XHR response", "status code", "error message");
        }
    } });