meh*_*595 4 extjs sencha-touch-2
我使用Sencha touch 2创建了navigaton视图.导航视图有列表组件,我想用存储和模型加载它.我根据需要创建了模型和商店.在运行我的应用程序时,列表不会呈现任何数据.它也会发出警告[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'}
]
}
});
Run Code Online (Sandbox Code Playgroud)
商店:
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'
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
视图:
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'
}
}
});
Run Code Online (Sandbox Code Playgroud)
有人可以指出我缺少什么/任何帮助赞赏.
列表中的store
属性items
需要是实例,而不是类的名称.GS.store.blogs
是班级名称.您需要使用Ext.create
并传递该实例来创建此类的实例items
.哦,是的,你的语法items
也是错误的.需要是一个数组[]
而不是一个对象{}
.所以类似于:
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
}]
}
});
Run Code Online (Sandbox Code Playgroud)