Reputation: 17034
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:
hasChanges()
work correctly without setting the Model ID
each grid? It seems like a little overhead to me.alternate
Upvotes: 1
Views: 496
Reputation: 1703
Kendo Grid has method getOptions() and there is property editable.
var grid = $("#grid").data("kendoGrid");
var options = grid.getOptions();
console.log(options.editable); //outputs true or false
I think schema.model.id is necessary because it's key property for CRUD operations. So you need it for hasChanges() to work properly.
Upvotes: 1