在Kendo网格中添加新记录

时间:2015-06-02 08:46:54

标签: javascript angularjs kendo-ui kendo-grid

我在kendo网格中保存新记录时遇到问题。当我更新网格时它正常工作,当我尝试添加新记录时,它没有。当我尝试在调试器,网络中调查问题时,我在POST过程中得到了这个(最后一个qutation标记丢失):

{ "Comment": "","OrderType": "43434343","Amount": "0","Status": "0","_MaterialKey": "83000000000","StartTime": "Tue Jun 02 2015 10:43:17 GMT+0200 }

这是参数图的一部分:

 transport: {
        read: {
          url: $("#gatewayPath").data("value") + "odata/ods/Plannings?$expand=Material($select=_Key,MaterialLocalName,MaterialGlobalName)&$select=_Key,OrderType,Amount,StartTime,Comment,Status",
          datatype: 'json',
          beforeSend: function (x) {
            var auth = $("#authenticationType").data("value") + " " + $("#authenticationToken").data("value");
            x.setRequestHeader("Authorization", auth);
          }
        },

       if (operation === "create")  {
              return '{ "Comment": "' + ((!data.Comment) ? "" : data.Comment) +
                      '","OrderType": "' + ((!data.OrderType) ? "" : data.OrderType) +
                      '","Amount": "' + ((!data.Amount) ? "0" : data.Amount) +
                      '","Status": "' + ((!data.Status) ? 0 : data.Status) +
                      '","_MaterialKey": "' + ((!data.Material) ? "83000000000" : data.Material._Key) +
                      '","StartTime": "' + ((!data.StartTime) ? 0 : data.StartTime) +
                 ' }';
        }
        else if (operation === "update") {
          if (data._Kendo_SaveIt == 1) {
              data._Kendo_SaveIt = 0;
              return '{ "_Key": "' + data._Key +
                     '","StartTime": "' + kendoHelper.getDate(data.StartTime) +                 
                     '","OrderType": "' + data.OrderType +
                     '","Amount": "' + data.Amount +
                     ((data.Material) ? '","_MaterialKey": "' + data.Material._Key : "") +
                     '","Comment": "' + data.Comment +
                     '","Status": "' + data.Status +
                     '"}';
          }
        }



 create: {
        url: function (data) {
          return $("#gatewayPath").data("value") + "odata/ods/Plannings?$expand=Material($select=_Key,MaterialLocalName,MaterialGlobalName)&$select=_Key,OrderType,Amount,StartTime,Comment,Status";
        },
        dataType: "json",
        type: "POST",
        beforeSend: function (x) {
          var auth = $("#authenticationType").data("value") + " " + $("#authenticationToken").data("value");
          x.setRequestHeader("Authorization", auth);
        }
      },
    update: {
      url: function (data) {
        return $("#gatewayPath").data("value") + "odata/ods/Plannings(" + data._Key + ")?$expand=Material($select=_Key,MaterialLocalName,MaterialGlobalName)&$select=_Key,OrderType,Amount,StartTime,Comment,Status";
      },
      dataType: "json",
      type: "PATCH",
      beforeSend: function (x) {
        var auth = $("#authenticationType").data("value") + " " + $("#authenticationToken").data("value");
        x.setRequestHeader("Authorization", auth);
      }
    }, 

0 个答案:

没有答案