mut*_*csm 19 javascript kendo-ui kendo-grid
如何检查Kendo Grid是否有变化?我听说有一处dirty房产,但我找不到.
Chr*_*ann 32
您可以在Grid的基础DataSource上使用'hasChanges'方法:
grid.dataSource.hasChanges();
$('#divGrid').data('kendoGrid').dataSource.hasChanges();
Run Code Online (Sandbox Code Playgroud)
car*_*rlg 20
添加的行将将dirty属性设置为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;
}
Run Code Online (Sandbox Code Playgroud)
您可以收到通知并使用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
})
Run Code Online (Sandbox Code Playgroud)
更新:如果用户更新了任何模型,则dataSource的.hasChanges()方法将返回true.
| 归档时间: |
|
| 查看次数: |
26851 次 |
| 最近记录: |