4
我已經使用Sencha touch 2創建了navigaton視圖。導航視圖具有我希望使用商店和模型加載它的列表組件。我根據需要創建了模型和商店。在運行我的應用程序時,列表不會顯示任何數據。 它還通過[Ext.dataview.List#applyStore] The specified Store cannot be found
發出警告。我不確定這個錯誤的含義。 這裏是我的MVC代碼,使用商店sencha touch將數據加載到列表中2
型號:
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'
}
}
});
有人能指出我什麼是缺少/ 任何幫助讚賞。
Ext.create將創建我的商店的新實例。如果我想在每個地方使用同一家商店,那麼我必須將其添加到我缺少的app.js'stores:['blogs']'中。此外'商店:'GS.store.blogs''我改爲'商店:'博客''現在工作正常。 – mehul9595 2012-04-01 08:33:41
此警告'[Ext.dataview.List#applyStore]無法找到指定的商店「已通過在博客商店中添加需要:['GS.model.BlogModel']'解決。 – mehul9595 2012-04-01 08:37:22
我創建了商店實例一次,然後使用'Ext.data.StoreManager.lookup'在任何地方使用同一家商店。很高興知道你的方式也行得通;我學到了新的東西:) – Jay 2012-04-01 09:42:19