[英]ExtJS: 2 ajax store, 1 with an extra row
我有以下代碼:
Ext.define('storeBusiness',{
extend: 'Ext.data.Store',
autoLoad: true,
autoSync: true,
model: 'Business',
proxy: {
type: 'ajax',
api: {
read: '../crud/ler_filter.php?db='+database+'&tbl=mercados',
create: '../crud/criar.php?db='+database+'&tbl=mercados',
update: '../crud/update.php?db='+database+'&tbl=mercados',
destroy: '../crud/apagar.php?db='+database+'&tbl=mercados'
},
reader: {
type: 'json',
root: 'rows'
},
writer: {
type:'json'
}
}
});
var storeBusinessCombo = Ext.create('storeBusiness');
var storeBusiness = Ext.create('storeBusiness');
storeBusiness.add({id: 0, business: "All"});
我有2個網格。 一個擁有storeBusiness ,另一個擁有storeProducts 。
當我單擊業務網格時,工作方式是過濾產品網格,以便顯示該業務的產品。 在業務網格上,它具有storeBusiness ,它從數據庫中獲取記錄。 我想從數據庫中獲取所有業務並添加一條記錄(名為“全部”)而不將其寫入數據庫。
我不想將“全部”添加到數據庫,因為在“產品”網格中,我想要一個組合框,其中包含所有業務( storeBusinessCombo )而沒有“全部”記錄。
有誰知道我該怎么做?
(上面的代碼沒有滿足我的要求, storeBusiness顯示所有業務,而網格中沒有“ All”)
重要提示:如果Ext.define('storeBusiness',具有類型為“ memory”的代理,則此方法有效
我想到兩種方法:
為了解決這個問題,我已經完成:
autoLoad: false,
輸入以下代碼:
var storeBusinessCombo = Ext.create('storeBusiness', {autoLoad: true}); var storeBusiness = Ext.create('storeBusiness'); storeBusiness.on('beforeload', function(){ storeBusiness.loadData([{id: 0, business: "All"}]); }
你應該把
storeBusiness.load({addRecords: true});
當您想加載storeBusiness
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.