Extjs Restful Store; Sending a request in batch mode?

I created the Grid component with the store configuration as follows:

    //Create the store
    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:

/**
 * Call this to delete selected items. No confirmation needed
 */
_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...

+3
2

; . , RESTful . , RESTful - . .

+2

, , :

,

Store RESTful, DataProxy RESTful, .

, Ext.data.Store /src/data/Store.js

309, @constructor

// If Store is RESTful, so too is the DataProxy
if (this.restful === true && this.proxy) {
    // When operating RESTfully, a unique transaction is generated for each record.
    // TODO might want to allow implemention of faux REST where batch is possible using RESTful routes only.
    this.batch = false;
    Ext.data.Api.restify(this.proxy);
}

, restful, batch true.

+6

Source: https://habr.com/ru/post/1779157/


All Articles