Reputation: 1097
$("#grid").kendoGrid({
dataSource: {
transport: {
read: function(options) {
$.ajax( {
url: "/api/mygetfunction",
data: options.data,
success: function(result) {
options.success(result);
}
});
},
update: function (options) {
$.ajax({
url: "/api/myupdatefunction",
data: options.data,
success: function (result) {
options.success(result);
}
});
},
destroy: function (options) {
$.ajax({
url: "/api/mydestroyfunction",
data: options.data,
success: function (result) {
options.success(result);
}
});
},
create: function (options) {
$.ajax({
url: "/api/mycreatefunction",
type: 'POST',
data: ...
});
},
parameterMap: function (options, operation) {
if (operation !== "read") {
return JSON.stringify(options);
}
}
},
schema: {
id: "Id",
model: {
fields: {
Id: { type: "string" },
Description: { type: "string" }
}
}
},
pageSize: 10,
serverPaging: false,
serverFiltering: false,
serverSorting: false,
batch: false
},
toolbar: ["create"],
filterable: true,
sortable: true,
pageable: true,
columns: [
{
field: "Description",
title: "Description"
},
{ command: ["edit", "destroy"], title: " ", width: "210px" }
],
editable: "inline"
});
The grid has 3 rows. When I click on edit, I change the description column. Then I Click Update, and the grid caals the 'create' of the transport configuration. I've set batch to false, and strangely, there are 3 create's instead of the changed row.
What's the reason the editing of the grid causes a create instead of update?
Upvotes: 1
Views: 1931
Reputation: 30661
This may happen if your records don't have an Id
field properly set. The data source considers all records that don't have id to be "new".
Upvotes: 3