如何检查Kendo Grid是否有更改?我听说有一个dirty
属性,但是我找不到了。
发布于 2012-10-05 02:44:25
添加的行将dirty属性设置为true,更新的行也将设置为true。但是,删除的行会存储在其他地方(在_destroyed集合中)。将此函数传递给您的网格的数据源,以查看它是否有更改。
function doesDataSourceHaveChanges(ds)
{
var dirty = false;
$.each(ds._data, function ()
{
if (this.dirty == true)
{
dirty = true;
}
});
if (ds._destroyed.length > 0) dirty = true;
return dirty;
}
发布于 2014-06-11 00:22:32
您可以在网格的底层DataSource上使用'hasChanges‘方法:
grid.dataSource.hasChanges();
$('#divGrid').data('kendoGrid').dataSource.hasChanges();
发布于 2012-10-05 04:36:03
您可以获得通知并使用page/sort/group/filter/create/read/update/delete记录的任何地方都会发生的dataSource的更改事件。
要将处理程序附加到它,请使用以下命令:
$('#YourGrid').data().kendoGrid.dataSource.bind('change',function(e){
//the event argument here will indicate what action just happned
console.log(e.action)// could be => "itemchange","add" or "remove" if you made any changes to the items
})
更新:如果用户更新了任何模型,dataSource的.hasChanges()方法将返回true。
https://stackoverflow.com/questions/12720543
复制相似问题