I've got some code which checks if a page has unsaved changes which is using the hasChanges() method of the Kendo dataSource to detect changes made within a grid:
var changed = self.data("kendoGrid").dataSource.hasChanges();
However, for the grid on one page this is failing because the isNew() method is missing from the data items within the dataSource. If I inspect the dataSource.data() items all of the items are present, but whereas the items on my other pages include a "dirty" field and an "isNew()" method the ones for this page do not. As far as I can tell there are no substantial differences between the pages. The one that works does have a couple of aggregates and a change event handler included in the dataSource which the failing one doesn't but I don't see how that would affect this.
Here is the div for the grid from the page that fails:
<div id="CentersGrid" data-bind="kendoGrid:
{
data: ReportingCenters,
widget: centersGrid,
dataSource: {
batch: true,
sort: { field: 'Number', dir: 'asc' } ,
},
scrollable: false,
pageable: { pageSize: 15, input: true, numeric: false },
editable: true,
sortable: true,
navigatable: true,
columns: [
{ field: 'id', hidden: true } ,
{ field: 'Number', width: '20%' } ,
{ field: 'Description', width: '60%' } ,
{ command: [ {name: 'destroy'} ] }
],
toolbar: ['create'],
dataBound: function(e) {
$('#CentersGrid tbody tr .k-grid-delete').each(function() {
var currentItem = $('#CentersGrid').data('kendoGrid').dataItem($(this).closest('tr'));
if (currentItem.CanDelete == false) { $(this).remove(); }
})
}
}">
The items that seem to be missing from each data item are: dirty, defaults, fields and isNew().
var changed = self.data("kendoGrid").dataSource.hasChanges();
However, for the grid on one page this is failing because the isNew() method is missing from the data items within the dataSource. If I inspect the dataSource.data() items all of the items are present, but whereas the items on my other pages include a "dirty" field and an "isNew()" method the ones for this page do not. As far as I can tell there are no substantial differences between the pages. The one that works does have a couple of aggregates and a change event handler included in the dataSource which the failing one doesn't but I don't see how that would affect this.
Here is the div for the grid from the page that fails:
<div id="CentersGrid" data-bind="kendoGrid:
{
data: ReportingCenters,
widget: centersGrid,
dataSource: {
batch: true,
sort: { field: 'Number', dir: 'asc' } ,
},
scrollable: false,
pageable: { pageSize: 15, input: true, numeric: false },
editable: true,
sortable: true,
navigatable: true,
columns: [
{ field: 'id', hidden: true } ,
{ field: 'Number', width: '20%' } ,
{ field: 'Description', width: '60%' } ,
{ command: [ {name: 'destroy'} ] }
],
toolbar: ['create'],
dataBound: function(e) {
$('#CentersGrid tbody tr .k-grid-delete').each(function() {
var currentItem = $('#CentersGrid').data('kendoGrid').dataItem($(this).closest('tr'));
if (currentItem.CanDelete == false) { $(this).remove(); }
})
}
}">
The items that seem to be missing from each data item are: dirty, defaults, fields and isNew().