简体   繁体   English

如何设置CRUD在剑道中工作?

[英]How to set CRUD working in Kendo?

How to set CRUD working in Kendo? 如何设置CRUD在剑道中工作? Update and read is ok, but create not. 可以更新和读取,但是不能创建。 This is my code for this part: 这是我这部分的代码:

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

and in parameterMap I have: 在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 + 
                '"}';
          }

There is a create example here on telerik.com . 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");
        }
    } });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM