Search code examples
extjsextjs4ext.net

Model validation before store sync


Listening on beforeSync event of store. Options parameter has hash of all records to be synchronized, broken down into create, update and destroy.

I need to validate them against their model validation rules.

Is it possible?

I tried this but it always returns true:

Ext.Array.forEach(options.create, function (item) {
    console.log(item.isValid());
});

Thanks


Solution

  • I've just realized that invalid records are not being inserted in hash of records to be synchronized (options parameter).

    Instead I can iterate through store's items:

    Ext.Array.forEach(st.data.items, function (item) {
        console.log(item.isValid())
    } );