2012-08-22 99 views
0

我爲我的網格使用了json服務。有3個網格,我使用相同的服務。我現在要做的是,在每次加載該服務的網格來自同一服務的3個不同的商店

storeGridEvents = new Ext.data.Store({ 
model: 'intern', 
proxy: { 
    url: storeUrl, 
    reader: { 
     type: 'json', 
     root: 'data' 
      } 
     } 
}); 

storeGridEventData = new Ext.data.Store({ 
model: 'dataEvents', 
proxy: { 
    url: storeUrl, 
    reader: { 
     type: 'json', 
     root: 'data' 
      } 
     } 
}); 

storeGridEventLocation = new Ext.data.Store({ 
model: 'locations', 
proxy: { 
    url: storeUrl, 
    reader: { 
     type: 'json', 
     root: 'data' 
      } 
     } 
}); 

有沒有辦法我加載服務只有一次,並將其用於三個型號?這將節省一些加載時間。

回答

1

您可以加載存儲一次,然後克隆它,這樣您將有兩個本地副本。

更新:我這裏是簡單克隆店功能:

cloneStore: function(store, storeClass) { 
    var new_st = Ext.create(storeClass), 
     recs = []; 

    store.each(function(r) { recs.push(r.copy)}); 
    new_st.add(recs); 

    return new_st; 
} 
+0

好感謝。我無法在extjs文檔中找到它。有沒有它的功能? –

+0

不是。你需要自己創建功能。讓我發表一些代碼。 – sha

相關問題