How can I check if a Kendo Grid has changes? I heard that there is a dirty
property, but I cant find it.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
grid.dataSource.hasChanges will let you know if the datasource has changed
The most convinient way to go is to use
datasource.hasChanges()
. However, this requires that theId
field is defined in the schema.From the docs:
If you do not have an Id field defined, you can use one of the countless ways to iterate over the data itself.
Added rows will have the dirty property set to true and so will updated rows. But, deleted rows are stored elsewhere (in the _destroyed collection). Pass this function the datasource of your grid to see if it has changes.
worth a try:
You can get notified and use the change event of the dataSource which will occur wherever you page/sort/group/filter/create/read/update/delete record.
To attach a handler to it use:
Update: If the user has updated any of the models .hasChanges() method of the dataSource will return true.
You can use the 'hasChanges' method on the Grid's underlying DataSource: