I am trying to do a create on a Kendo Grid to a C# WebAPI and I get a error
errorThrown: SyntaxError: Unexpected end of JSON input at Object.parse (native) at n.parseJSON
There is nothing in the query string and the object is coming back null
$(document).ready(function () {
$("#btnInsert").on("click", function () {
$("#btnInsert").on("click", function () {
var grid = $('#SupplierGrid').data('kendoGrid');
grid.addRow();
});
});
$("#SupplierGrid").kendoGrid({
height: 700,
resizeable: true,
sortable: true,
pageable: true,
columns: [
{ field: "supplierNumber", title: "Product ID", width: 13 }, // Product ID
{ field: "supplierDesc", title: "Product Pack", width: 14 }, // Product Pack
{ field: "corpei", title: "Processing Fee", width: 15 }], // Processing Fee
filterable: true,
dataSource: {
transport: {
read: {
url: "/Supplier/GetSuppliers",
cache: false,
datatype: "json"
},
update: {
url: "/Supplier/Updatesupplier",
dataType: "json",
},
create: {
url: "/Supplier/CreateSupplier",
dataType: "json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation !== "read" && operation !== "create" && options) {
return { models: kendo.stringify(options) };
}
}
},
change: function (e) {
if (e.action == "itemchange") {
this.sync();
}
},
schema: {
data: "Data",
total: "Total",
model: {
id: "supplierNumber",
fields: {
supplierNumber: { type: "string", editable: true },
supplierDesc: { type: "string", editable: true },
corpei: { type: "string", editable: true },
isActive: { type: "string", editable: false }
}
}
},
pageSize: 15,
requestEnd: function (e) {
var response = e.response;
var type = e.type;
if (type == window.undefined) {
// showError();
var popupNotification = $("#popupNotification").kendoNotification(
{
position: {
top: $(document).height() / 2 + 300,
right: $(document).width() / 2
},
allowHideAfter: 500,
stacking: "down"
}
).data("kendoNotification");
var staticNotification = $("#staticNotification").kendoNotification({
appendTo: "#appendto"
}).data("kendoNotification");
popupNotification.show("Save Failed", "error");
}
else {
if (type == 'update') {
var popupNotification = $("#popupNotification").kendoNotification(
{
position: {
top: $(document).height() / 2 + 300,
right: $(document).width() / 2
},
allowHideAfter: 500,
stacking: "down"
}
).data("kendoNotification");
var staticNotification = $("#staticNotification").kendoNotification({
appendTo: "#appendto"
}).data("kendoNotification");
popupNotification.show("Cell Saved", "success");
}
}
}
},
scrollable: true,
Batch: true,
navigatable: true,
editable: { //disables the deletion functionality
update: true,
destroy: false
},
serverPaging: true,
resizeable: true,
serverSorting: true
});
$('#SupplierGrid').data('kendoGrid').dataSource.bind("error", dataSource_error);
});
function dataSource_error(e) {
}
[HttpPost]
public JsonResult CreateSupplier(supplier s)
{
supplier model = null;
}
Aucun commentaire:
Enregistrer un commentaire