使用商店Sencha Touch 2将数据加载到List中,不显示

时间:2015-08-20 21:28:29

标签: javascript extjs extjs4 sencha-touch sencha-touch-2.1

我跟随de示例在这里发布关于使用商店Sencha Touch 2将数据加载到List中它似乎工作但是当我尝试这样做时不显示任何东西

我是sencha touch的新手,我不太了解它 有人能告诉我我做错了什么吗?

这是代码:

主:

var blogsStore = Ext.create("GS.store.blogs"); //put this in the items list
Ext.define('GS.view.Main',{
extend:'Ext.navigation.View',
xtype:'blog',
requires:[
    'Ext.dataview.List',
    'Ext.data.proxy.JsonP',
    'Ext.data.Store',
    'GS.store.blogs',
    'GS.model.BlogModel'
],
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
         }
     ]

}
});

型号:

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',
requires: [
    'GS.model.BlogModel',
    'Ext.data.proxy.JsonP',
],
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'
            }
        }
}
});

app.js:

Ext.application({
name: 'GS',

requires: [
    'Ext.MessageBox'
],

views: [
    'Main'
],

stores: [
    'blogs'
],

models:[
    'BlogModel'
],

icon: {
    '57': 'resources/icons/Icon.png',
    '72': 'resources/icons/Icon~ipad.png',
    '114': 'resources/icons/Icon@2x.png',
    '144': 'resources/icons/Icon~ipad@2x.png'
},

isIconPrecomposed: true,

startupImage: {
    '320x460': 'resources/startup/320x460.jpg',
    '640x920': 'resources/startup/640x920.png',
    '768x1004': 'resources/startup/768x1004.png',
    '748x1024': 'resources/startup/748x1024.png',
    '1536x2008': 'resources/startup/1536x2008.png',
    '1496x2048': 'resources/startup/1496x2048.png'
},

launch: function() {
    // Destroy the #appLoadingIndicator element
    Ext.fly('appLoadingIndicator').destroy();

    // Initialize the main view
    Ext.Viewport.add(Ext.create('GS.view.Main'));
},

onUpdated: function() {
    Ext.Msg.confirm(
        "Application Update",
        "This application has just successfully been updated to the latest version. Reload now?",
        function(buttonId) {
            if (buttonId === 'yes') {
                window.location.reload();
            }
        }
    );
}
});

1 个答案:

答案 0 :(得分:0)

我发现了错误 在声明rootProperty时,我尝试访问返回的json中的'entries'元素,但此属性不存在 然后你应该修改rootProperty:

rootProperty:'responseData.feed'

现在app app rigth

相关问题