2012-06-19 13 views
1

我的代碼有一個錯誤,但我無法弄清楚什麼是錯的。 我嘗試在點擊NestedList的葉子項時在Store中設置新的url。 這裏是我的商店:如何在商店代理中設置網址?

Ext.define('Application.store.DetailStore', { 
extend: 'Ext.data.Store', 

config: { 
    model: 'Application.model.DetailModel', 
    autoLoad :true, 
    sorters: 'title', 
    grouper : function(record) { 
     return record.get('title')[0]; 
     }, 

    proxy: { 
    type: 'ajax', 
    url : '/data/data1.php', 
    reader: { 
    type: 'json', 
    rootProperty:'recipes'} 
     } 
} 

});

這是NestedList我leafitemtap的聽衆:

onLeafItemTap: function(nestedList, list, index, node, record, e) { 
    filter = record.get('text'); 
    var detailCard = nestedList.getDetailCard();  
    Ext.getStore('Application.store.DetailStore').getProxy().setUrl('/data/data2.php'); 
    Ext.getStore('Application.store.DetailStore').load() 
} 

這個我上無法敲擊葉項目和細節卡不顯示了。 有誰知道什麼可能是錯的?

回答

0

下面我使用了getMain方法,當點擊葉子項目並加載商店時,將detailCard推到列表頂部。我還假設您正在使用getMain作爲參考,在您的控制器中定義leafitemtap邏輯。

你也可以用它代替「Application.store.DetailStore」

 Ext.getStore('Application.store.DetailStore').setProxy({ 
     type: 'ajax', 
     url: '/data/data2.php' 
    }).load({ 
     callback: function(records, operations, success) { 
      if (success = true) { 
       this.getMain().push({ 
        xtype: 'detailsCard', 
        data: record.getData() 
       }) 
      } else { 
       Ext.Msg.alert('Error', 'Something went wrong!', Ext.emptyFn); 
      } 
     }, 
     scope: this 
    }); 
+0

回讀了,如果你想要做的是設置並加載店只寫問題的STOREID:Ext.getStore(」 Application.store.DetailStore')。setProxy({type:'ajax', url:'/data/data2.php'})。load() 而不是使用getProxy和setUrl –

+0

感謝您的回覆!但它沒有幫助,我仍然不能點擊葉子項目。我測試了刪除代碼的一些部分,當我在Ext.getStore('Application.store.DetailStore')之後寫東西時,它停止工作。 –

+0

您可以發佈從存儲中獲取的NestedList視圖,模型和JSON嗎? –