我正在尝试将JSON数据加载到NestedList中。我有以下的存储文件在/app/ store /Ex接触器中。
Ext.define('VisitTCMIndy.store.Exhibits',{
requires: ['VisitTCMIndy.model.Exhibit', 'Ext.data.proxy.JsonP'],
extend: 'Ext.data.TreeStore',
config: {
model: 'VisitTCMIndy.model.Exhibit',
proxy: {
type: 'jsonp',
url: 'http://www.example.com/explore.php',
reader: {
type: 'json',
rootPropery: 'children'
}
}
}
});
然后,我在/app/ view /爆炸物. in中的以下视图中引用它
Ext.define('VisitTCMIndy.view.Explore', {
extend: 'Ext.Container',
requires: [
'Ext.data.TreeStore',
'Ext.dataview.NestedList',
'VisitTCMIndy.store.Exhibits',
],
xtype: 'explorecard',
config: {
iconCls: 'compass1',
title: 'Explore',
layout: 'fit',
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Explore'
},
{
xtype: 'nestedlist',
fullscreen: true,
store: 'VisitTCMIndy.store.Exhibits',
detailCard: {
html: 'Explore Details'
},
listeners: {
leafitemtap: function(nestedList, list, index, target, record){
var detailCard = nestedList.getDetailCard();
detailCard.setHtml('Exhibit Title: '+ record.get('title'));
}
}
}
]
}
});
当我转到页面时,我会得到以下警告和一个空列表:
警告无法找到指定的存储区
在我的生活之前,我不知道我做错了什么。
发布于 2013-02-15 18:55:23
好的。结果,我不得不在我的app.js文件中声明我的存储和模型。然后,请参考我的商店,只需使用它的名称,而不需要类定义的其余部分。因此,我将以下内容添加到我的app.js文件中:
models: ['Exhibit'],
stores: ['Exhibits'],
然后,这里是我更新的Explore.js视图文件。
Ext.define('VisitTCMIndy.view.Explore', {
extend: 'Ext.Container',
requires: [
'Ext.data.TreeStore',
'Ext.dataview.NestedList',
'VisitTCMIndy.store.Exhibits',
],
xtype: 'explorecard',
config: {
iconCls: 'compass1',
title: 'Explore',
layout: 'vbox',
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Explore'
},
{
xtype: 'nestedlist',
store: 'Exhibits',
title: 'Museum Levels',
displayField: 'title',
detailCard: {
html: 'Explore Details'
},
listeners: {
leafitemtap: function(nestedList, list, index, target, record){
var detailCard = nestedList.getDetailCard();
detailCard.setHtml('<div style="text-align:center;margin:.5em;"><img src="'+record.get('image')+'" alt="'+record.get('title')+'" />'+
'<p style="text-align:left;">'+record.get('text')+'</p></div>'
);
}
},
flex: 1
}
]
}
});
另外,注意我将布局从fit更改为vbox。我不得不这样做,并给列表一个灵活的1,这样列表才能真正显示现在它正在加载数据。
https://stackoverflow.com/questions/14900967
复制相似问题