Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sencha touch 2 存储区未显示的Sencha数据视图_Sencha Touch 2_Sencha Touch 2.1 - Fatal编程技术网

Sencha touch 2 存储区未显示的Sencha数据视图

Sencha touch 2 存储区未显示的Sencha数据视图,sencha-touch-2,sencha-touch-2.1,Sencha Touch 2,Sencha Touch 2.1,我是sencha touch的新手,在使用带有ajax存储的dataview时遇到了问题 下面是我的代码: 在我的app.js的发布部分: Ext.define('SocializeApp.model.Friends', { extend: 'Ext.data.Model', config: { fields: [ {name:'name' ,type:'string'}, {

我是sencha touch的新手,在使用带有ajax存储的dataview时遇到了问题

下面是我的代码:

在我的app.js的发布部分:

Ext.define('SocializeApp.model.Friends', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {name:'name' ,type:'string'},
                {name:'id' ,type:'string'},
                {name:'img' ,type:'string'}
            ]
        }
    });
    Ext.define('SocializeApp.store.FriendStore', {
        extend: 'Ext.data.Store',
        config: {
            model: 'SocializeApp.model.Friends',
            storeId: 'FriendStore',
            proxy: {
                type: 'ajax',
                url: 'http://socialize.localhost.com/friends.php',
                reader: {
                    type: 'json',
                    rootProperty: 'friends'
                },
                autoLoad: 'true'
            },

        }
    });

    Ext.Viewport.add(Ext.create('SocializeApp.view.Main'));
在Main.js中

  Ext.define('SocializeApp.view.Main', {
    extend: 'Ext.tab.Panel',
    fullscreen: true,
    xtype: 'main',
    requires: ['Ext.TitleBar'],
    config: {
        tabBarPosition: 'bottom',
        items: [{
            title: 'Amigos',
            iconCls: 'team',
            items: [{
                xtype: 'dataview',
                store: 'FriendStore',
                scrollable: {
                    direction: 'vertical'
                },
                tpl: ['{img} {id} {name}']
            }]
        }, {
            title: 'time',
            iconCls: 'time',
            items: [{
                html: '<h1> game </h1><src="resources/img/socialize-button.png" alt=""/>',
            }]
        }, {
            title: 'Interesses',
            iconCls: 'bookmarks',
            items: [{
                docked: 'top',
                xtype: 'titlebar',
                title: 'Getting Started'
            }, {
                xtype: 'video',
                url: 'http://av.vimeo.com/64284/137/87347327.mp4?token=1330978144_f9b698fea38cd408d52a2393240c896c',
                posterUrl: 'http://b.vimeocdn.com/ts/261/062/261062119_640.jpg'
            }]
        }]
    }
});
我真的很感谢你的帮助

Thx,

试试这些(代码结合了这些想法)

1-为dataview提供一个itemId,并在view initialize方法中加载存储。可能还需要尝试将自动加载设置为false

2-有时我还显式地给出完整的存储引用,而不仅仅是id,例如ex Ext.getStore('FriendStore')

3-你在使用MVC吗?你是否在app.js中声明了你的商店/模型

Ext.application({
     name: 'yourapp',
     stores: ['FriendStore'],
     models: ['Friends'],
     launch: function() {   
          ...
     }
});
4-或者,想想这个。。将您的tpl更改为“itemTpl”

Ext.define('SocializeApp.view.Main', {
    extend: 'Ext.tab.Panel',
    fullscreen: true,
    xtype: 'main',
    requires: ['Ext.TitleBar', 'SocializeApp.store.FriendStore'],
    config: {
        tabBarPosition: 'bottom',
        items: [{
            title: 'Amigos',
            iconCls: 'team',
            items: [{
                itemId: 'FriendsDataview',
                xtype: 'dataview',
                store: Ext.getStore('FriendStore'),
                scrollable: {
                    direction: 'vertical'
                },
                itemTpl: ''.concat(
                    '<div>{img} {id} {name}</div>'
                )
            }]
        }, {
            title: 'time',
            iconCls: 'time',
            items: [{
                html: '<h1> game </h1><src="resources/img/socialize-button.png" alt=""/>',
            }]
        }, {
            title: 'Interesses',
            iconCls: 'bookmarks',
            items: [{
                docked: 'top',
                xtype: 'titlebar',
                title: 'Getting Started'
            }, {
                xtype: 'video',
                url: 'http://av.vimeo.com/64284/137/87347327.mp4?token=1330978144_f9b698fea38cd408d52a2393240c896c',
                posterUrl: 'http://b.vimeocdn.com/ts/261/062/261062119_640.jpg'
            }]
        }]
    },

    initialize: function(){
        var store = Ext.getStore('FriendStore');
        var dv = Ext.ComponentQuery.query('dataview[itemId=FriendsDataview]')[0];
        dv.setStore(store);
        store.load(function(){
            console.log(this); 
        });
    }
});
Ext.define('eapp.view.Main'{
扩展:“Ext.tab.Panel”,
全屏:对,
xtype:'main',
要求:['Ext.TitleBar','SocializeApp.store.FriendStore'],
配置:{
tabBarPosition:'底部',
项目:[{
标题:“朋友们”,
iconCls:“团队”,
项目:[{
itemId:“FriendsDataview”,
xtype:“数据视图”,
存储:Ext.getStore('FriendStore'),
可滚动:{
方向:“垂直”
},
itemTpl:''.concat(
“{img}{id}{name}”
)
}]
}, {
标题:"时代",,
iconCls:“时间”,
项目:[{
html:'游戏',
}]
}, {
标题:“利息”,
iconCls:“书签”,
项目:[{
停靠:“顶部”,
xtype:'标题栏',
标题:“入门”
}, {
xtype:'视频',
网址:'http://av.vimeo.com/64284/137/87347327.mp4?token=1330978144_f9b698fea38cd408d52a2393240c896c',
posterUrl:'http://b.vimeocdn.com/ts/261/062/261062119_640.jpg'
}]
}]
},
初始化:函数(){
var store=Ext.getStore('FriendStore');
var dv=Ext.ComponentQuery.query('dataview[itemId=FriendsDataview]')[0];
dv.setStore(商店);
load(函数(){
console.log(this);
});
}
});
Ext.define('SocializeApp.view.Main', {
    extend: 'Ext.tab.Panel',
    fullscreen: true,
    xtype: 'main',
    requires: ['Ext.TitleBar', 'SocializeApp.store.FriendStore'],
    config: {
        tabBarPosition: 'bottom',
        items: [{
            title: 'Amigos',
            iconCls: 'team',
            items: [{
                itemId: 'FriendsDataview',
                xtype: 'dataview',
                store: Ext.getStore('FriendStore'),
                scrollable: {
                    direction: 'vertical'
                },
                itemTpl: ''.concat(
                    '<div>{img} {id} {name}</div>'
                )
            }]
        }, {
            title: 'time',
            iconCls: 'time',
            items: [{
                html: '<h1> game </h1><src="resources/img/socialize-button.png" alt=""/>',
            }]
        }, {
            title: 'Interesses',
            iconCls: 'bookmarks',
            items: [{
                docked: 'top',
                xtype: 'titlebar',
                title: 'Getting Started'
            }, {
                xtype: 'video',
                url: 'http://av.vimeo.com/64284/137/87347327.mp4?token=1330978144_f9b698fea38cd408d52a2393240c896c',
                posterUrl: 'http://b.vimeocdn.com/ts/261/062/261062119_640.jpg'
            }]
        }]
    },

    initialize: function(){
        var store = Ext.getStore('FriendStore');
        var dv = Ext.ComponentQuery.query('dataview[itemId=FriendsDataview]')[0];
        dv.setStore(store);
        store.load(function(){
            console.log(this); 
        });
    }
});