Extjs 4.1-如何在initComponent函数中创建项
我有一个像这样的面板Extjs 4.1-如何在initComponent函数中创建项,extjs,extjs4.1,Extjs,Extjs4.1,我有一个像这样的面板 var filterPanel = Ext.create('Ext.panel.Panel', { bodyPadding: 5, width: 300, myValue:5, title: 'Filters', initComponent: function() { this.items = [{ xtype: 'textfield',
var filterPanel = Ext.create('Ext.panel.Panel', {
bodyPadding: 5,
width: 300,
myValue:5,
title: 'Filters',
initComponent: function() {
this.items = [{
xtype: 'textfield',
value: this.myValue
}];
this.callParent();
}
renderTo: Ext.getBody()
});
我尝试创建一个具有xtype:'textfield'
的项目,其值为面板的myValue
。但这是失败
怎么做谢谢。
下面是我的示例文本您正在使用
Ext.create()
函数,该函数用于创建类的实例<当使用Ext.define()
函数定义类时,可以使用code>initComponent方法,我不确定initComponent
函数使用Ext.create()
方法将不起作用
例如,参见下面的代码,它将得到执行:
Ext.define('customPanel', {
extend: 'Ext.panel.Panel',
bodyPadding: 5,
width: 300,
myValue:5,
title: 'Filters',
initComponent: function() {
this.items = [{
xtype: 'textfield',
value: this.myValue
}];
this.callParent(arguments);
},
renderTo: Ext.getBody()
});
Ext.create('customPanel');