Store do something after sync with autoSync enabled

后端 未结 3 1347
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 01:45

I\'m trying to detect and remove those fields that after a sync are still on the store but are not added to the database (success: false). Then, return an error message to t

3条回答
  •  长情又很酷
    2020-12-15 02:13

    This is, if you ask me, some design flaw in ExtJS.

    AbstractStore has onCreateRecords, onUpdateRecords, and onDestroyRecords, which are empty functions you can override. You can call rejectChanges() if success is false there.

    Ext.define('BS.store.Users', {
        extend: 'Ext.data.Store',    
        model: 'BS.model.User',
    
        autoSync: true,
        autoLoad: true,
    
        proxy: {
            type: 'direct',
            api: {
                create: Users.Create,
                read: Users.Get,
                update: Users.Update,
                destroy: Users.Delete,
    
            },
            reader: {
                type: 'json',
                root: 'data',
            },
        },
    
        onCreateRecords: function(records, operation, success) {
            console.log(records);
        },
    
        onUpdateRecords: function(records, operation, success) {
            console.log(records);
        },
    
        onDestroyRecords: function(records, operation, success) {
            console.log(records);
        },
    
    });
    

提交回复
热议问题