I currently want to iterate about each Kendo Grid, and warn the user, if there are pending changes. For this I use the method hasChanges()
(I use batch editing):
$(".k-grid").each(function () {
if ($(this).data('kendoGrid').dataSource.hasChanges()) {
//Warn user about pending changes
}
}
This works fine.
However, I have some readonly Grids which should return always false. The Problem is, they always return true (which is impossible, because they can not be edited).
I investigated the differences, and the problem is, that my readonly grids have not the Model ID
in the AjaxDataSourceBuilder<TModel>
defined:
.Model(model => model.Id(entity => entity.SomeId)
They must be defined to get false
from hasChanges()
on a readonly grid.
My Question:
- Can I make
hasChanges()
work correctly without setting theModel ID
each grid? It seems like a little overhead to me.
alternate
- Can I check at runtime via JS, if the grid is editable?