I have a grid that has the following code as the update action in its datasource.
This is being called before the grid is rendered so I get an error that the datasource is null. Meaning I dont think the grid has initialized on the front end so the '#Grid' isnt there for the returnDirtyFields method to get. Why is this update action data method being run when the grid is not updating?
The .Data() method I want with the update action below it.
function
returnDirtyFields(gridId) {
var
id =
'#'
+ gridId;
var
dataSource;
var
data;
var
changedModels;
dataSource = $(id).data(
"kendoGrid"
).dataSource;
data = dataSource.data();
if
(dataSource.hasChanges()) {
for
(
var
i = 0; i < data.length; i++) {
if
(data[i].dirty) {
changedModels = data[i].dirtyFields
}
}
}
var
temp = $.extend(
true
, {}, { dirtyFields: JSON.stringify(changedModels) });
return
temp;
}
.Update(update => update.Action(
"Entry_Update"
,
"Entry"
).Data(
"returnDirtyFields('Grid')"
))