我想在商店类中添加一个功能来清理商店(代理+数据+同步),我可以通过myStoreVariable.cleanAll();
或Ext.getStore('storeId').cleanAll();
我的第一次尝试就是这个,但我无法从商店调用此功能:
Ext.data.Store.cleanAll = function() {
this.getProxy().clear();
this.data.clear();
this.sync();
};
我的第二次尝试就是:
this.storeStore = Ext.create('Ext.data.Store', { id: 'myStore', model: 'myModel' });
this.storeStore.cleanAll = function() { /* my cleaning code(see above) */ };
它正在运作,但我不想为我的所有商店定义cleanAll。
您知道是否有可能将此功能添加到商店类?所以我可以通过Ext.create('Ext.data.Store',
答案 0 :(得分:0)
我找到了一种方法,覆盖/添加方法Ext.data.Store
将此代码放入Ext.Application
launch: function() {
Ext.override(Ext.data.Store, {
cleanAll: function() {
this.getProxy().clear();
this.data.clear();
this.sync();
}
});
}