我在 ASP.Net MVC 中有 Kendo UI 网格。我正在尝试将JSON
对象传递给控制器。虽然我在控制器中得到一个对象,但属性是NULL
(名字,姓氏)。我们怎样才能纠正它?
注意:对象不为空;但对象中的属性为空
JSON
var NewPerson = new Object();
NewPerson.FirstName = "A";
NewPerson.LastName = "B";
var json1 = { myPerson: NewPerson };
return json1;
JavaScript
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: {
type: "aspnetmvc-ajax",
transport: {
dataType: "json",
//,type: "POST"
read: {
url: "Home/GetItemsData",
data: function ()
{
var NewPerson = new Object();
NewPerson.FirstName = "A";
NewPerson.LastName = "B";
var json1 = { myPerson: NewPerson };
return json1;
}
}
},
schema: {
model: {
fields: {
Program: {
ItemID: "number",
},
ItemDescription: { type: "string" }
}
},
total: "Total",
data: "Items"
},
serverPaging: true,
serverSorting: true,
serverFiltering: true,
pageSize: 5
},
scrollable: false,
sortable: true,
pageable: true,
columns: [
{ field: "ItemID", title: "Item Id", width: "70px" },
{ field: "ItemDescription", title: "Item Description", width: "110px" }
]
});
控制器
public JsonResult GetItemsData(Person myPerson, [DataSourceRequest] DataSourceRequest request)
{
}