繁体   English   中英

通过ajax代理进行CRUD批量更新/插入

[英]CRUD bulk update/insert through an ajax proxy

我正在通过ajax代理进行批量更新/插入。 我使用store.sync()它将为每条脏记录击中服务器,但是如果我在服务器中的任何一条记录中遇到错误,如何用适当的消息通知客户端?

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
}

通过sync更新store时,可以使用三种方法。 onUpdateRecordsonDestroyRecordsonCreateRecords 您可以查看success属性返回并rejectChanges

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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