Send all records of a Extjs store to server at once

喜你入骨 提交于 2019-12-10 14:56:22

问题


How can I send my entire store data to the server in one POST call? It could be in json format.

thanks.

Update:

this is my store code:

Ext.define('App.store.consultorio.Receita', {
    extend: 'Ext.data.Store',
    model: 'App.model.consultorio.Receita',
    autoLoad: false,
    proxy: {

        type: 'rest',
        reader: {
            type: 'json'
        },
        writer: {
            type: 'json'
        },
        url: 'consultas/receita.json'
    }
});

回答1:


You could set every record in the store dirty, then call sync()

store.each(function(record){
    record.setDirty();
});

store.sync();

Also, your store is using a RESTful proxy, which by default does not batch actions. See http://docs.sencha.com/ext-js/4-2/#!/api/Ext.data.proxy.Rest-cfg-batchActions

Your store should look like:

Ext.define('App.store.consultorio.Receita', {
    extend: 'Ext.data.Store',
    model: 'App.model.consultorio.Receita',
    autoLoad: false,
    proxy: {

        type: 'rest',
        batchActions: true, //<------
        reader: {
            type: 'json'
        },
        writer: {
            type: 'json'
        },
        url: 'consultas/receita.json'
    }
});


来源:https://stackoverflow.com/questions/15954363/send-all-records-of-a-extjs-store-to-server-at-once

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!