Sencha Touch 2: "The specified store was not found"
I am trying to load JSON data into a NestedList. I have the following store file at /app/store/Exhibits.js
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'
}
}
}
});
Then I refer to it in the following view at /app/view/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: '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'));
}
}
}
]
}
});
When navigating to the page, I get the following warning and an empty list:
[WARN] [Ext.dataview.NestedList # applyStore] The specified store was not found
Turn me on, I can't figure out what I'm doing wrong.
source to share
Ok. It turns out I had to declare my store and model in the app.js file. Then refer to my store by name only, without the rest of the class definition. So, I added the following to my app.js file:
models: ['Exhibit'],
stores: ['Exhibits'],
Then, here's my updated Explore.js view file.
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
}
]
}
});
Also, please note that I changed the layout from fit to vbox. I had to do this and give the list a flex of 1 so that the list would actually show now that it was loading data.
source to share