4
votes

I have created navigaton view using Sencha touch 2. Navigation view has list component which i want to load it using store and model. I created model and store as required. On running my app the list does not render any data. It also gives warning in conolse [Ext.dataview.List#applyStore] The specified Store cannot be found . I am not sure what this error means. Here is my mvc code,

model:

Ext.define('GS.model.BlogModel', {
extend: 'Ext.data.Model',

config: {
    fields: [
        {name: 'title', type: 'auto'},
        {name: 'author', type: 'auto'},
        {name: 'content', type:'auto'}
      ]
    }
});

store:

Ext.define('GS.store.blogs',{
extend:'Ext.data.Store',
config:{
    model:'GS.model.BlogModel',
    autoLoad :true,
    proxy:{
                type:'jsonp',
                url:'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
                reader:{
                    type:'json',
                    rootProperty:'responseData.feed.entries'
                }
            }
}
});

view:

Ext.define('GS.view.Blog',{
extend:'Ext.navigation.View',
xtype:'blog',
requires:[
    'Ext.dataview.List',
    'Ext.data.proxy.JsonP',
    'Ext.data.Store',
    'GS.store.blogs'
],
config: {
    title:'Blog',
    iconCls:'star',
    items:{
        xtype:'list',
        itemTpl:'{title}',
        title:'Recent Posts',
        store:'GS.store.blogs'
    }

}
});

Can someone point me out what is missing/ Any help appreciated.

1

1 Answers

6
votes

The store property in items for your list needs to be an instance, not the name of the class. GS.store.blogs is the class name. You need to create an instance of this class using Ext.create and pass that instance in items. Oh yeah, and your syntax for items is wrong too. Needs to be an array [] not an object {}. So something like:

var blogsStore = Ext.create("GS.store.blogs"); //put this in the items list

Ext.define('GS.view.Blog',{
    extend:'Ext.navigation.View',
    xtype:'blog',
    requires:[
        'Ext.dataview.List',
        'Ext.data.proxy.JsonP',
        'Ext.data.Store',
        'GS.store.blogs'
    ],
    config: {
        title:'Blog',
        iconCls:'star',
        items:[{
            xtype:'list',
            itemTpl:'{title}',
            title:'Recent Posts',
            store: blogsStore //Store instance here. And items are in array, not Object
         }]

    }
});