简体   繁体   中英

CRUD bulk update/insert through an ajax proxy

I was working on bulk update/insert through an ajax proxy. I use store.sync() this will hit the server for every dirty records but if I get error in any one of the record in server, how to notify the client with proper message?

proxy: {
        type: 'ajax',
        url: "localhost:8888/service/baseLocations",
        reader: {
            type: 'json',
            rootProperty: 'data',
            successProperty: 'success',
            totalProperty : 'total'
        },
        actionMethods: {
            create: 'POST',
            read: 'GET',
            update: 'POST',
            destroy: 'DELETE'
        },
        writer : {
            type: 'json'
        },
        batchActions: false
}

There are three methods available when a store is updated via sync . onUpdateRecords , onDestroyRecords , and onCreateRecords . You can view the success property coming back and rejectChanges

For Example : onUpdateRecords: function(records, operation, success) { if (!success){ this.rejectChanges(); } } onUpdateRecords: function(records, operation, success) { if (!success){ this.rejectChanges(); } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM