0

전체 검도 그리드를 다시 게시하려고하면 컨트롤러에 개체가 수신되지 않고 null로 처리됩니다. 도구 모음에 사용자 지정 단추를 추가 했으므로 클릭하면 다시 게시해야합니다. 피들러 요청에 게시 된 데이터가 표시되지만 컨트롤러에서 수신 할 수 없습니까?Kendo 그리드에서 데이터를 컨트롤러에 null로 게시

이것은 피들러에서의 HTTP POST 요청

POST http://localhost:59457/api/data/SaveBill HTTP/1.1 호스트를 캡처 : 로컬 호스트 : 59,457 연결 : 연결 유지 콘텐츠 길이 : 24 수락 : 응용 프로그램/JSON을, 텍스트/일반, / 원산지 : http://localhost:59457 사용자 에이전트 : 모질라/5.0 (윈도우 NT 6.1, Win64를; 64) AppleWebKit/537.36 (KHTML, 도마뱀 붙이 등) 크롬/48.0.2564.116 사파리/537.36 의 Content-Type : application/json; charset = UTF-8 리퍼러 : http://localhost:59457/ 수락 - 인코딩 : gzip을을, 폐의 수락 - 언어 : EN-US, 욕실, Q = 0.8

[{ "ID": 1, "이름": "존"}]

을 (각도)

 $scope.mockdata = new kendo.data.ObservableArray([{ 
      "Id": 1, 
       "Name": "John" 
       }, { 
       "Id": 2, 
       "Name": "Joe" 
       }, { 
       "Id": 3, 
       "Name": "Jack" 
       }]); 

        $scope.sportsGrid = new kendo.data.DataSource({ 
        // data: $scope.mockdata, 
        transport: { 
         read: function (e) { 
          e.success($scope.mockdata); 
       }, 
        update: function (e) { 
           console.log("Update", e); 
           }, 
             destroy: function(e) { 
           console.log("Destroy", e); 
         }, 
            create: function(e) { 
         console.log("Create", e); 
        }, 
            parameterMap: function (options, operation) { 
           if (operation !== "read" && options.models) { 
            return { 
             models: kendo.stringify(options.models) 
         }; 
         } 
         } 
         }, 
          batch: false, 
              pageSize: 5, 
          change: function (e) { 
         console.log("change: " +e.action); 
         if (e.action === "remove") { 
                this.sync(); 
             } 
          // do something with e 
         }, 
           schema: { 
              model: { 
            id: "Id", 
            fields: { 
            Id: { 
             type: "number" 
             }, 
             Name: { 
             type: "string" 
             } 

            } 
            } 
             } 
            }); 



    $scope.options = { 
       sortable: true, 
        pageable: true, 
       editable: true, 
       toolbar: ["create", "cancel", { 
        text: "Custom" 
      }], 
       columns: [{ 
       field: "Id", 
        title: "ID" 
     }, { 
      field: "Name", 
      title: "Name" 
     }, { 
        command: ["destroy"], 
         title: " ", 
          width: "150px" 
         }], 
        edit: function(e) { 
      if (e.model.Name == "Joe") { 
       this.closeCell(); 
       } 

     } 

       }; 
    $("#sportsSetupGrid").on("click", ".k-grid-Custom", function (e) { 
     var models = JSON.stringify($("#sportsSetupGrid").data().kendoGrid._data); 


     $http({ 
     method: 'POST', 
     url: 'api/data/SaveBill', 
     data: models, 
     contentType: "application/json", 
      dataType:"JSON" 

    }); 
      e.preventDefault() 
      }); 
JS에 내 컨트롤러

public IHttpActionResult SaveBillingGroupMap([FromBody]test models) 
     { 
      var x = HttpContext.Current.Request.InputStream; 
      //var employees = this.DeserializeObject<IEnumerable<test>>("models"); 
      throw new NotImplementedException(); 
     } 

    public class test 
     { 
      public int Id { get; set; } 

      public string Name { get; set; } 
} 

코드에

코드

이는 HTML

 <div kendo-grid k-options="options" k-data-source="sportsGrid" id="sportsSetupGrid" ></div> 

답변

0

당신은 자바 스크립트의 조치 방법 SaveBill를 호출에 컨트롤러에 액션 메소드 이름은 SaveBillingGroupMap입니다. 이것을 수정하면 제어기의 메소드가됩니다.

관련 문제