【发布时间】:2011-09-26 19:24:38
【问题描述】:
我对 Sencha Touch 有点陌生,所以请多多包涵。
在应用启动时,我将视口设置为我使用的视口,并将所有视图设置为应用命名空间。
launch: function() {
this.views.viewport = new this.views.Viewport();
this.views.homecard = this.views.viewport.getComponent('home');
this.views.usercard = this.views.viewport.getComponent('user');
this.views.infocard = this.views.viewport.getComponent('info');
}
视口首先加载主视图,这就是我遇到的问题。 这是我的家庭名片:
ToolbarDemo.views.Homecard = Ext.extend(Ext.Panel, {
title: "Meny",
iconCls: "home",
scroll: "vertical",
bodyStyle: "background-color: #FFFFFF !important; background-image: url(images/background.png) !important; background-repeat:no-repeat; background-position:bottom left;",
initComponent: function()
{
ToolbarDemo.views.Homecard.superclass.initComponent.apply(this, arguments);
},
store:ToolbarDemo.stores.feedStorer,
tpl:buttonTemplate,
dockedItems:
[
{
xtype: "toolbar"
}
],
defaults: {height: "110px"},
});
这是我的模板:
var buttonTemplate = new Ext.Template
(
'<tpl for=".">',
' <div class="home_button_container">',
' <img class="home_button" src="{url_icon_large}" />',
' <p class="home_button_text">{name}</p>',
' </div>',
'</tpl>'
);
这是我的模型:
Ext.regModel('Feeds', {
fields: [
{name: 'name', type: 'string'},
{name: 'url_icon_small', type: 'string'},
{name: 'url_icon_medium', type: 'string'},
{name: 'url_icon_large', type: 'string'},
{name: 'url_icon_large_p', type: 'string'},
{name: 'url', type: 'string'},
{name: 'sort_order', type: 'string'}
]
});
这是我的商店:
ToolbarDemo.stores.feedStore = new Ext.data.Store({
model: 'Feeds',
storeId: 'feedStore',
proxy: {
type: 'scripttag',
url : 'http://localhost/webservice/feeds.php?username=' + sUsername + '&password=' + sPassword,
reader: {
type: 'json',
root: 'feeds'
}
},
autoLoad: true
});
这是 JSON:
{"feeds":[{"name":"Links","url_icon_small":"http:url/link_small.png","url_icon_medium":"url/link_medium.png","url_icon_large":"url /link_large.png","url":"url/feed_content.php?type=link","sort_order":"1"}],"updated":[{"last_updated":"2011-06-09 11:15:47"}]}
问题是这个视图上什么都没有显示,我怀疑模型可能有问题? 我已经登录了商店,我可以看到它获取了应有的数据。
有人有解决此问题的建议吗?
提前致谢
EDIT(得到关于 DataView 的提示): 扩展面板更改:
ToolbarDemo.views.Homecard = new Ext.Panel({
title: "Meny",
iconCls: "home",
scroll: "vertical",
bodyStyle: "background-color: #FFFFFF !important; background-image: url(images/background.png) !important; background-repeat:no-repeat; background-position:bottom left;",
initComponent: function()
{
ToolbarDemo.views.Homecard.superclass.initComponent.apply(this, arguments);
},
dockedItems:
[
{
xtype: "toolbar"
}
],
defaults: {height: "110px"},
items: new Ext.DataView(
{
tpl:buttonTemplate,
store: ToolbarDemo.stores.feedStorer,
autoHeight:true,
multiSelect: true,
loadingText: 'Laster data',
itemSelector:'div.home_button_container',
emptyText: 'No images to display'
})
});
【问题讨论】:
标签: model sencha-touch store