2013-04-07 77 views
0

嗨,我有一个应用程序,使用代理填充商店。我想单击按钮清除商店,并让用户输入不同的信息并重新填充,如果有意义的话。我目前使用:清除存储sencha

window.location.reload(); 

但这给了几秒钟的白色屏幕,这是不好的。我也曾尝试以下操作:

var store = Ext.getStore('Places'); 

store.getProxy().clear(); 

store.data.clear(); store.sync(); 

但这给出了与.getProxy()

错误我也尝试:

Ext.StoreMgr.get('Places').removeAll(); 
Ext.StoreMgr.get('Places').sync(); 

但是当我去重新填充旧数据仍然存在。有没有办法清除商店?

+0

'VAR店= Ext.getStore( '邻居'); store.removeAll();'不工作? – SachinGutte 2013-04-08 03:02:36

+0

我认为这个问题可能是因为我的selectfields没有返回到它们的初始值。并且当用户再次搜索时,相同的参数被传回。我尝试用下列方法清除它们,但没有成功:var visitEmpty = this.getVisit()。setValue('food | restaurant |'); var location = this.getLocation()。setValue('currentlocation'); var radiusEmpty = this.getRadius()。setValue('1'); – paulpwr 2013-04-08 16:14:49

回答

4

清除存储的最佳方式是

  var store = Ext.getStore('SessionStore'); 
     store.load(); 
     store.getProxy().clear(); 
     store.data.clear(); 
     store.sync(); 
+0

嗨,我已经尝试了上述,我得到错误消息未捕获TypeError:对象[对象对象]没有方法'明确' – paulpwr 2013-04-08 14:42:17

+0

我认为这个问题可能与我的selectfields没有返回到它们的初始值。并且当用户再次搜索时,相同的参数被传回。我尝试用下列方法清除它们,但没有成功:var visitEmpty = this.getVisit()。setValue('food | restaurant |'); var location = this.getLocation()。setValue('currentlocation'); var radiusEmpty = this.getRadius()。setValue('1'); – paulpwr 2013-04-08 16:12:06