这是精简版的代码:
gridDataSource = new kendo.data.DataSource({
batch: true,
transport: {
read: {
url: 'Equipment'
},
destroy: {
url: 'Equipment',
contentType: "application/json",
dataType: 'json',
type: "DELETE"
},
parameterMap: function (options, operation) {
if (operation == "read") {
return "this=works-fine";
} else {
alert('not reading');
return kendo.stringify(options.models);
}
}
},
schema: {
id: "EquipmentId",
fields: {
Value: { type: "number" }
}
}
});
kendoGrid = gridObj.kendoGrid({
dataSource: gridDataSource,
selectable: 'row',
navigatable: true,
change: rowSelect,
sortable: true,
pageable: false,
columns: [
{ field: "Value" },
]
}).data('kendoGrid');
并且读取工作得很好,我用这个删除了一行(或很多行)(selectedRow 填充正确,为简洁起见略过):
$('#footer-remove').off().on('click', function () {
kendoGrid.removeRow('table tr[data-uid="' + selectedRow.uid + '"]');
console.log(gridDataSource._destroyed);
});
它出现在 gridDataSource._destroyed 中,我所有的测试都表明 gridDataSource 是脏的。
当我调用同步时,如果我只是删除,什么都不会发生。我错过了什么?谢谢你。