【问题标题】:Extjs one store bind to more comboboxExtjs 一个商店绑定到更多组合框
【发布时间】:2013-06-13 01:21:47
【问题描述】:

我有一个问题:一个商店绑定到多个组合框;

例如

combobox_1 绑定到 store_1,combobox_2 也绑定到 store_1,当展开 combobox_1 时,加载 store_1。然后展开combobox_2,store_1再次加载。

但我不想加载 store_1 两次,因为 store 已经加载了!我该如何解决这个问题?

【问题讨论】:

  • 您可以使用具有相同代理的单独存储。但是如果您不想进行两次拉取请求,那么您可以将内存类型用于第二个存储,然后在第二个复制第一个存储,如果是这样的话你想要的。
  • 你能贴一些代码吗?

标签: extjs combobox store


【解决方案1】:

例如,在Controller上,我们将在加载组合商店事件上使用一个函数:

init : function() {

   this.getNameComboStore().on('load', this.functionLoadStore, this); 

},

...

functionLoadStore : (store){

 if(store.count>0){
   store.suspendEvents(false); // break the load event (supends all events)
   store.resumeEvents(); // resume the event, it's IMPORTANT!
 }

}

在函数中,我们比较元素charge的个数,如果count>0,则挂起load事件,再次恢复。

【讨论】:

  • 我使用了queryMode='local',解决了这个问题。使用这个配置,商店不会从远程加载数据。
猜你喜欢
  • 2012-01-16
  • 1970-01-01
  • 2013-07-26
  • 2013-02-04
  • 2021-06-10
  • 2020-06-22
  • 1970-01-01
  • 1970-01-01
  • 2014-03-11
相关资源
最近更新 更多