0
votes

I want to add a function to the Store Class for cleaning the store(proxy+data+sync), which I can call it via myStoreVariable.cleanAll(); or Ext.getStore('storeId').cleanAll();

My first attempt is this, but I can't call this function from the store:

Ext.data.Store.cleanAll = function() {
     this.getProxy().clear();
     this.data.clear();
     this.sync();
};

My second attempt is this:

this.storeStore = Ext.create('Ext.data.Store', { id: 'myStore', model: 'myModel' });
this.storeStore.cleanAll = function() { /* my cleaning code(see above) */ };

It is working, but I don't want to define cleanAll for all of my stores.

Do you know any possibility to add this function to the store class? So I can call it from any store I create via Ext.create('Ext.data.Store',

1
Are you defining your own store classes? Or you just instantiate Ext.data.Store?sha
I am just creating them. Ext.create('Ext.data.Store', { id: 'myId', model: 'myModel' });. But I want the function for all stores.Niklas
@sha I updated the post.Niklas

1 Answers

0
votes

I found a way, overriding / adding a method to Ext.data.Store

Put this code into your launch config of your Ext.Application

launch: function() {
    Ext.override(Ext.data.Store, {
        cleanAll: function() {
            this.getProxy().clear();
            this.data.clear();
            this.sync();
        }
    });
}