I`m trying to show/hide an ext.js (xtype:"compositefield") with an listener from a combo. All works well, except the composite field's Label won't hide. How do I select the whole composite field DOM element so i can use .hide()/.show() on it ?
the code for compositefield:
xtype: 'compositefield',
labelStyle: 'width: 60px',
fieldLabel: 'Player 1',
id: "player_1_fields",
msgTarget: 'under',
items:[
{xtype: 'displayfield', value: 'Name',margins: '3 5 0 22'},
{xtype: 'textfield', name: 'props_name_1', width: 135},
{xtype: 'displayfield', value: 'Score',margins: '3 5 0 0'},
{xtype: 'numberfield', name: 'props_score_n1', width: 35}
]
the code for listener:
listeners: {
select: function(combo, record, index) {
if ( combo.getValue() == "2" )
{
Ext.getCmp("player_1_fields").getEl().hide();
}
else
{
Ext.getCmp("player_1_fields").getEl().show();
}
}
}
Try this code:
select: function(combo, record, index) {
if ( combo.getValue() == "2" ) {
Ext.getCmp("player_1_fields").getEl().up('.x-form-composite').hide();
} else {
Ext.getCmp("player_1_fields").getEl().up('.x-form-composite').show();
}
}
Up should find parent with a specific class (and you want that to be ExtJs class for whole form item).