I have Kendo UI grid in ASP.Net MVC. I am trying to pass JSON
object to controller. Though I am getting an object in the controller, the properties are coming as NULL
(FirstName, LastName). How can we correct it?
Note: The object is not null; but the properties are null in the object
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" }
]
});
Controller
public JsonResult GetItemsData(Person myPerson, [DataSourceRequest] DataSourceRequest request)
{
}