Extjs4 EXTJS 4-为XTemplate提供数据
我是extjs新手,在向模板提供数据时遇到问题Extjs4 EXTJS 4-为XTemplate提供数据,extjs4,Extjs4,我是extjs新手,在向模板提供数据时遇到问题 var header = new Ext.Template("<div><b>{name}</b></div>"); header.compile(); var description = new Ext.Template("<div><b>{description}</b></div>"); description.compile(); Ext.d
var header = new Ext.Template("<div><b>{name}</b></div>");
header.compile();
var description = new Ext.Template("<div><b>{description}</b></div>");
description.compile();
Ext.define('ActivityWindow', {
extend : 'Ext.window.Window',
id : 'detActWin',
layout : 'border',
config :{
resultRecord : null
},
defaults :{
xtype : 'panel'
},
constructor: function (args){
this.initConfig(args);
this.callParent();
},
items : [
{
tpl : header,
itemId : 'activityHeader',
region : 'north',
data : this.resultRecord
},
{
html : 'partecipantsList',
itemId : 'activityPartecipants',
region : 'east'
},
{
html : 'description',
region : 'center'
}
]
});
var winDetAct = Ext.create(ActivityWindow, { resultRecord: entry});
alert(winDetAct.getResultRecord().get('name')); //it shows the field name
winDetAct.show();
问题:
1-如何将变量resultRecord中的数据提供给窗口第1项中的模板?
2-有没有合适的方法来做到这一点
多谢各位,
Gabriel您看到的问题是,this.resultRecord未定义,因为此上下文尚未作为配置的组件提供。您必须调用initComponent,并且在其中可以有这个.Myproperty引用。Her是经过修改的代码,可以正常工作:
非常感谢DmitryB,不幸的是,当我点击你的链接时,我得到了一个空白项目,但无论如何,谢谢你,我会仔细考虑它。对链接感到抱歉:试试这个:只是不要在IE中运行它-这个愚蠢的东西没有控制台。
data : this.resultRecord