问题
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