How do I check if a Kendo Grid has had changes made to it?

前端 未结 6 954
我在风中等你
我在风中等你 2021-02-12 10:58

How can I check if a Kendo Grid has changes? I heard that there is a dirty property, but I cant find it.

6条回答
  •  星月不相逢
    2021-02-12 11:40

    The most convinient way to go is to use datasource.hasChanges(). However, this requires that the Id field is defined in the schema.

    From the docs:

    Checks if the data items have changed. Requires an [ID field] to be configured in schema.model.id, otherwise will always return true.

    If you do not have an Id field defined, you can use one of the countless ways to iterate over the data itself.

    var isDataSourceDirty = function (ds) {
        var dirty = ds._data.filter(function(x){
            return x.dirty === true;
        });
        return dirty.length > 0 || ds._destroyed.length;
    };
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题