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

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

问题描述

我使用 Sencha touch 2 创建了导航视图.导航视图具有列表组件,我想使用商店和模型加载它.我根据需要创建了模型和存储.在运行我的应用程序时,列表不会呈现任何数据.它还在 conolse [Ext.dataview.List#applyStore] The specified Store cannot be found 中给出警告.我不确定这个错误是什么意思.这是我的 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.

推荐答案

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

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

    }
});

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

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