Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send all records of a Extjs store to server at once

Tags:

extjs

extjs4

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'
    }
});
like image 812
Beetlejuice Avatar asked Apr 11 '13 16:04

Beetlejuice


1 Answers

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'
    }
});
like image 175
James Avatar answered Sep 28 '22 04:09

James