如何在剑道中设置 CRUD 工作

How to set CRUD working in Kendo?

本文关键字:设置 CRUD 工作      更新时间:2023-09-26

如何在剑道中设置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);
          }
        },

在参数映射中,我有:

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");
        }
    } });