我正在尝试查看使用子元素创建自定义组件是否是一种好方法。在我的大多数表单中,我都会有一些水平对齐的字段,大小相同。
我的第一个想法是创建一个自定义FieldContainer
并且已经声明了我现在将存在的项目,但我不想在这个扩展类中设置他的名字和 ID。我想让最后一个班级负责,也许还有子项目的更多属性。
那么,可以在将使用我的自定义组件的类中定义配置的 o 子项吗?
例子
Ext.define('MyApp.view.LookupContainer', {
extend: 'Ext.form.FieldContainer',
layout: {
type: 'column'
},
labelAlign: 'right',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'numberfield',
columnWidth: 0.15,
width: 70,
labelWidth: 0,
maxValue: 99999,
minValue: 0
},
{
xtype: 'textfield',
columnWidth: 0.75,
margin: '0 0 0 5',
readOnly: true
},
{
xtype: 'button',
cls: 'x-formButton',
margin: '0 0 0 5',
overCls: 'x-formButtonOver',
iconCls: 'icon-lov'
},
{
xtype: 'button',
margin: '0 0 0 5',
iconCls: 'icon-program'
}
]
});
me.callParent(arguments);
}
});
Ext.onReady(function() {
var container = Ext.create('MyApp.view.LookupContainer');
//how to set the items properties here?
});