PDA

View Full Version : get value of fieldLabel



andryi
11 Aug 2009, 8:20 AM
Hi all,
I've a problem with a field label, here is the code:

here I declare a button


var sp_BtnCall = new Ext.Action({
text: '<u>L</u>lamar',
width:78,
handler: function(){
alert('Message: ' + Ext.getCmp('sp_LblMsg').getValue);
// alert('Message: ' + Ext.getCmp('sp_LblMsg').getFieldLabel);
},
iconCls: 'icoLlamar'
});
here is my form


{
layout:'form',
id:'frmMsg',
name:'frmMsg',
labelWidth: 175,
frame:true,
bodyStyle:'padding:5px 5px 0',
autoWidth: true,
autoHeight: true,
defaults: {width: 230},
items: [{
id: 'sp_LblMsg',
name: 'sp_LblMsg',
fieldLabel: 'No clients'
}]
}
and this layout is in a FormPanel, and the problem is, how can I get the value of the fieldLabel can anyone help me?

tryanDLS
11 Aug 2009, 9:09 AM
fieldLabel is a property of the Field - there is no get method to access it.


Ext.getCmp('sp_LblMsg').fieldLabel);

andryi
11 Aug 2009, 9:32 AM
thank's :D, and if I want to change the value, it will be :


Ext.getCmp('sp_LblMsg').setFieldLabel("new value");

,isn't it?

Animal
11 Aug 2009, 9:41 AM
Ext.override(Ext.form.Field, {
getLabel: function() {
return this.el.up('.x-form-element').prev('label');
}
});

Animal
11 Aug 2009, 9:42 AM
In Ext 3.1, the FormLayout puts the label element in as a property.