如何设置CRUD在剑道中工作

如何设置CRUD在剑道中工作

如何设置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");
        }
    } });

09-25 17:09