When performing an update on the grid it sends all column data.
How can I Send only changed (with dirty class) data?
2 Answers, 1 is accepted
0
Konstantin Dikov
Telerik team
answered on 22 Apr 2019, 03:28 PM
Hello Dron,
There is no built-in functionality that will pass only the changed values of the model, but you could handle the "parameterMap" of the dataSource to modify the returned data. You can then find the corresponding items (using the ID field) in the dataSource.view() collection and get reference to the "dirtyFields" collection, where you will find all changed fields. Using the model in the event handler and the dataItem from the dataSource (and the dirtyFields collection), you can return the stripped model:
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.Learn More.
parameterMap: function(options, operation) {
var idCode = 'CargoID';
if (operation === "update") {
var res = grid.data("kendoGrid").dataSource.view();
var dirtyFields = {};
for (var i = 0; i < res.length; i++) {
if (res[i].dirty === true) {
dirtyFields[res[i][idCode]] = {};
$.each(res[i]['dirtyFields'], function(index, value) {
if (res[i][idCode] === options[idCode]) {
dirtyFields[res[i][idCode]][index] = res[i][index];
}
});
}
}
return dirtyFields;
}
}
This is suboptimal code. I wrote it last night after my main job. But it works.
Спасибо, Костян, за помощь. Будешь в Москве - пиши. С меня пиво!