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()
}

在此之后我无法点击叶子项目并且详细卡不显示。有谁知道可能出了什么问题?

4

1 回答 1

0

下面我使用 getMain 方法在点击叶子项目并加载商店时将 detailCard 推送到列表顶部。我还假设您正在使用 getMain 作为参考在控制器中定义leafitemtap 逻辑。

您还可以使用 storeId 代替“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
    });
于 2012-06-19T23:22:51.520 回答