使用商店sencha touch 2将数据加载到List中

时间:2012-03-31 19:24:13

标签: extjs sencha-touch-2

我使用Sencha touch 2创建了navigaton视图。导航视图有列表组件,我想使用商店和模型加载它。我根据需要创建了模型和商店。在运行我的应用程序时,列表不会呈现任何数据。 它还在conolse [Ext.dataview.List#applyStore] The specified Store cannot be found中发出警告。我不确定这个错误意味着什么。 这是我的mvc代码,

模型:

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

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

存储

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'
                }
            }
}
});

视图:

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'
    }

}
});

有人能指出我缺少什么/ 任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:6)

列表中store的{​​{1}}属性需要是实例,而不是类的名称。 items是类名。您需要使用GS.store.blogs创建此类的实例,并在Ext.create中传递该实例。哦是的,你items的语法也是错误的。需要是数组items而不是对象[]。如下所示:

{}