This particular question is part of a discussion regarding How to set defaults for Grid columns within initComponent. It has been shared here independently as per the advice given by @scebotari66 in the main post.
Below, you can see the use of Ext.Array.map
to define default values for related functions.
// Statement
initComponent: function () {
var me = this;
me.items = Ext.Array.merge(
me.getFormSt(),
Ext.Array.map(me.getForm(), function (listFldConfig) { //Utilizing array map function to set flex property for subset fields
listFldConfig.flex = 1;
return listFldConfig;
}),
me.getFormEnd()
);
me.callParent(arguments)
},
// Implementation
getForm: function () {
var me = this;
var form = [
{ // Array.map func. sets `flex` to this obj.
xtype: 'fieldcontainer',
layout: { type: 'vbox', align: 'stretch', pack: 'start' },
items: [
{
xtype: 'fieldcontainer',
layout: 'hbox',
items: [
{
xtype: 'foofield',
//flex: 1 //However, I aim to set `flex` as default for this object in the nested items array
},
{
xtype: 'barfield',
//flex: 1 //Nevertheless, I intend to set `flex` as default for this object in the nested items array
}
The current implementation works as intended, but in this scenario, I am creating a fieldcontainer
object that includes all other elements and items inside. The use of Array.map
only applies the flex
configuration to the first fieldcontainer
object. My requirement is to specify the flex
configuration solely for the nested items
containing foofield
and barfield
.