[英]Sencha Touch add function to Sencha Component
我想向商店类添加一个函数以清理商店(proxy + data + sync),我可以通过myStoreVariable.cleanAll();
来调用它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',
我找到了一种方法,将方法覆盖/添加到Ext.data.Store
将此代码放入Ext.Application
启动配置中
launch: function() {
Ext.override(Ext.data.Store, {
cleanAll: function() {
this.getProxy().clear();
this.data.clear();
this.sync();
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.