PDA

View Full Version : Howto display a hidden label



sKuD24
2 Feb 2010, 7:19 AM
Hi,

I have a textfield :
var textField = new Ext.form.TextField({
fieldLabel : i18n.label,
msgTarget : 'under',
name : 'text',
allowBlank : true,
anchor : '95%',
hidden : true,
hideLabel : true
});

and a combobox :
var comboBox = new Ext.stsi.YesNoComboBox({
fieldLabel : i18n.combo,
name : 'combo',
valueField : 'combo',
value : false,
allowBlank : false,
msgTarget : 'under',
displayField : 'libelle',
emptyText : i18n.yesnoEmptyTextCB
});
I want display the the label of my textfield when I select a value of my combobox.
I did this :
comboBox.on('select',function(){
if(comboBox.getValue() == true){
textField.hideLabel = false;
textField.allowBlank = false;
textField.setVisible(true);
}else{
textField.hideLabel = true;
textField.setVisible(false);
}
});

The field is displayed but not the field label.
What's wrong ?
Someone have a solution ?

sherpam
27 Aug 2010, 7:14 AM
Simple solution (which I use and works like charm) is on 2nd post (the one by webpaul) of this thread:
Hiding the combobox and the label sometime? (http://www.sencha.com/forum/showthread.php?17396-Hiding-the-combobox-and-the-label-sometime&p=83149#post83149).
And more elaborated solutions are discussed and linked below that post.

I refactored a little to use a single method for show and hide (maybe someone needs that too):


var setVisibleWithLabel = function(field, isVisible) {
field.setDisabled(!isVisible);// for validation
field.setVisible(isVisible);
field.getEl().up('.x-form-item').setDisplayed(isVisible); // hide label
};

sherpam
27 Aug 2010, 7:24 AM
Simple solution (which I use and works like charm) is on 2nd post (the one by webpaul) of this thread:
Hiding the combobox and the label sometime? (http://www.sencha.com/forum/showthread.php?17396-Hiding-the-combobox-and-the-label-sometime&p=83149#post83149)
And more elaborated solutions are discussed and linked below that post.

I refactored a little to use a single method for show and hide (maybe someone needs that too):


var setVisibleWithLabel = function(field, isVisible) {
field.setDisabled(!isVisible);// for validation
field.setVisible(isVisible);
field.getEl().up('.x-form-item').setDisplayed(isVisible); // hide label
};