Using a "destroy" command in the datagrid and "autoSync: false", it somehow calls the "destroy" twice. Any idea if I'm doing something wrong? When I set autoSync to true, it only fires once.
The following config gives me:
destroy destroy success success
destroy: (options) => {
console.log("destroy");
$.ajax({
url: $discountProductsGrid.data("delete-url"),
dataType: "json",
contentType: 'application/json',
type: "POST",
data: kendo.stringify({
discountNumber: options.data.discountNumber,
productNumber: options.data.productNumber,
productColorId: options.data.productColorId,
productSizeId: options.data.productSizeId,
}),
success: (result) => {
console.log("success");
options.success(result);
},
error: (result) => {
console.log("error");
options.error(result);
},
});
},
I do have sorting, filtering, and paging on the server, though I don't expect that to matter.
My model isn't very complicated and I've verified that there are no double IDs. At first I was thinking that perhaps the response body was incorrect, but that shouldn't be a problem because it fires the same destroy twice and doesn't wait for the first destroy to finish.
kendo.data.Model.define({
id: "discountLineId",
fields: {
discountLineId: {type: "string"},
discountNumber: {type: "number"},
productSupplierName: {type: "string"},
productCategoryDescription: {type: "string"},
productNumber: {type: "number"},
productId: {type: "string"},
productDescription: {type: "string"},
productColorId: {type: "string"},
productColorDescription: {type: "string"},
productSizeId: {type: "string", nullable: true},
productSizeDescription: {type: "string", nullable: true},
discountSalesPrice: {type: "number"},
productSalesPrice: {type: "number"},
discountSalesPricePercentage: {type: "number"},
}
})
$discountLineGrid.on("click", ".k-grid-save-changes", (e) => {
e.preventDefault();
discountLineGrid.saveChanges();
// sync also firesd
// discountLineDataSource.sync();
});
I've verified inside the data source (in the range part), that the data is only 19 and that only the one record is that has to be deleted is still in the prestine data or whatever that is.