Я отправляю json из сетки кендо, когда я удаляю строку, но в контроллере я получаю ноль.
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
type: "POST",
dataType: "json",
url: "/Home/GetPatients"
},
destroy: {
url: '@Url.Action("deletePatient", "Home")',
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options)
return kendo.stringify(options);
}
},
schema: {
model: {
id: "Id",
fields: {
FirstName: { type: "string" },
LastName: { type: "string" },
CNP: { type: "string" },
Birthdate: { type: "date" }
}
}
},
pageSize: 20,
},
height: 300,
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
toolbar: ["create"],
columns:
[
{ field: "LastName", title: "Nume" },
{ field: "FirstName", title: "Prenume" },
{ field: "CNP", title: "CNP" },
{ field: "Birthdate", title: "Data nasterii", format: "{0:dd/MM/yyyy}" },
{
command:
[
{
name: "edit"
},
{
name: "destroy",
}
],
title: "", width: "172px"
}
],
editable: "popup"
});
});
Я помещаю отладку здесь в метод, и фактический параметр 'j' равен нулю, он долженбыть строкой (сериализация JSON).В chrome -> режим отладки -> сеть -> я получил статус 200 в порядке, и в запросе полезной нагрузки я просматриваю json со всеми данными строки, что хорошо, но я застрял.
[HttpPost]
public ActionResult deletePatient(string j)
{
//List<Patient> objName = new JavaScriptSerializer().Deserialize<List<Patient>>(j);
int a = 5;
a = a - 4;
return Json(a);
}