【发布时间】:2013-06-21 16:00:48
【问题描述】:
我有一个自定义 Ext.Component 和一个视图 XTemplates。我确实需要一些在我的控制器视图之外的模板。
是否可以在 XTemplate 的函数中引用静态成员。还是有其他更好的方法???
类似这样的:
Ext.define('app.view.ApplicationHeader', {
extend: 'Ext.Component',
name: 'app-header',
xtype: 'app-header',
height: 67,
margin: 0,
statics: {
mainIconTpl: new Ext.XTemplate('someTemplate'),
navigationItemsTpl: new Ext.XTemplate( 'anotherTemplate'),
userInfoTpl: new Ext.XTemplate('userTemplate')
},
html: new Ext.XTemplate('... {[ this.renderMainIcons() ]} {[ this.renderUserInfo() ]} ...',
'... {[ this.renderNavigationBarItems() ]} ...',
{
me: this,
renderMainIcons: function () {
return view.static.mainIconTpl.apply(MR.Sitemap.Items);
},
renderUserInfo: function () {
return view.static.userInfoTpl.apply();
},
renderNavigationBarItems: function () {
return view.static.navigationItemsTpl.apply();
}
}).apply()
});
我也不知道如何应用属于视图成员的子模板。我宣布他们是全球性的,知道我真的不喜欢做什么。
请!
【问题讨论】:
-
我看不出您提出的解决方案有什么问题...除非您应该使用
app.view.ApplicationHeader.mainIconTpl,而不是可能未定义的view.mainIconTpl。你遇到了什么样的失败? -
问题是我没有在这个 XTemplate 函数中获得我的视图上下文...:/
-
如果它们在同一个视图中,我不知道如何在我的 XTemplate 中获取静态模板.. 我不能使用 this.self... 因为这已经是 XTemplate
-
app也没有定义..
标签: javascript templates extjs static extjs4.2