I created the Grid component with the store configuration as follows:
config.store = new Ext.data.Store({
restful: true,
autoSave: false,
batch: true,
writer: new Ext.data.JsonWriter({
encode: false
}),
reader: new Ext.data.JsonReader({
totalProperty: 'total',
root: 'data',
fields: cfg.fields
}),
proxy: new Ext.data.HttpProxy({
url:cfg.rest,
listeners:{
exception: {
fn: function(proxy, type, action, options, response, arg) {
this.fireEvent('exception', proxy, type, action, options, response, arg);
},
scope: this
}
}
}),
remoteSort: true,
successProperty: 'success',
baseParams: {
start: 0,
limit: cfg.pageSize || 15
},
autoLoad: true,
listeners: {
load: {
fn: function() {
this.el.unmask();
},
scope: this
},
beforeload: {
fn: function() {
this.el.mask("Working");
},
scope: this
},
save: {
fn: function(store, batch, data) {
this.el.unmask();
this.fireEvent('save', store, batch, data);
},
scope: this
},
beforewrite: {
fn: function(){
this.el.mask("Working...");
},
scope: this
}
}
});
Note. Ignore fireEvents. This store is configured in the general user component Grid.
However, I have one problem: no matter what CRUD actions I did, I always get N requests to the server, which is equal to N lines that I selected. that is, if I select 10 rows and delete Delete, 10 DELETE requests will be sent to the server.
For example, I delete entries:
_deleteSelectedItems: function() {
var selections = this.getSelectionModel().getSelections();
if (selections.length > 0) {
this.store.remove(selections);
}
this.store.save();
this.store.reload();
},
Note: The scope of this is a grid component.
So, is that so? Or is my configuration problem? I am using Extjs 3.3.1 and according to the documentation batchin the Ext.data.Store section,
Store RESTful, DataProxy RESTful, .
, .
. listful, encode, writeAllFields, encodeDelete Ext.data.JsonWriter...