使用存储sencha触摸将数据加载到列表中2 [英] Loading data into List using store sencha touch 2

查看:94
本文介绍了使用存储sencha触摸将数据加载到列表中2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Sencha touch创建了导航视图2.导航视图具有列表组件,我想使用存储和模型加载它。我根据需要创建模型和商店。在运行我的应用程序时,列表不会显示任何数据。
它也在conolse中发出警告 [Ext.dataview.List#applyStore]指定的Store无法找到。我不知道这个错误是什么意思。
这是我的mvc代码,

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,

模型:

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

}
});

有人可以指出什么是缺少/
任何帮助赞赏。

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

推荐答案

项目中的存储属性为您的列表需要一个实例,而不是类的名称。 GS.store.blogs 是类名。您需要使用 Ext.create 创建此类的实例,并将该实例传递到项目中。哦,是的,你的项目的语法也是错误的。需要是一个数组 [] 不是一个对象 {} 。所以这样的东西:

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

    }
});

这篇关于使用存储sencha触摸将数据加载到列表中2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆