剣道グリッド全体をポストしようとすると、コントローラーにオブジェクトが表示されず、ヌルとして表示されます。私はツールバーにカスタムボタンを追加しました。それをクリックすると、ポストバックが行われます。フィドラーリクエストは、データがポストバックされていることを示していますが、コントローラーで受信できません。剣道のグリッドをコントローラに戻してヌルとして投稿する
これは、HTTP POSTリクエスト
POST http://localhost:59457/api/data/SaveBill HTTP/1.1 ホスト、シオマネキからキャプチャされた:ローカルホスト:59457 接続:キープアライブ のContent-Length:24 が受け入れ:アプリケーション/ JSONを、 text/plainで、/ 原産地:http://localhost:59457 のUser-Agent:Mozillaの/ 5.0(Windows NTの6.1; Win64の、x64の)のAppleWebKit/537.36(KHTML、ヤモリなど)クローム/ 48.0.2564.116サファリ/ 537.36 のContent-Type:アプリケーション/ json; charset = UTF-8 リファラー:http://localhost:59457/ 受け入れエンコード:GZIPを、収縮 受け入れ言語:EN-US、EN; 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; }
}
コード上
コード
これはあなたがJavaScriptでアクションメソッドSaveBill
を呼び出していると、コントローラでのアクションメソッド名がSaveBillingGroupMap
されるHTMLに
<div kendo-grid k-options="options" k-data-source="sportsGrid" id="sportsSetupGrid" ></div>