2012-06-19 17 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吗? –