-
14 Jul 2011 12:45 AM #1
Dynamically Changing the Form label
Dynamically Changing the Form label
Hello,
Is there any way to change the field label in the form dynamically?
if you have any ideas please guide me to do this.
Thanks in advance
-
14 Jul 2011 6:39 AM #2
Hello.
Actually there is not a function like "setLabel" defined for "Ext.form.Field" components that makes you change easily the label value.
However, I wrote you a simple example that show you how to do what you request.
What I do in this example is take the wanted Field component from the form and then change the innerHTML of the labelEl.Code:Ext.setup({ onReady: function() { var form = new Ext.form.FormPanel({ fullscreen: true, dockedItems: [{ xtype: 'toolbar', title: 'Example', items: [{ xtype: 'button', text: 'Change Label', handler: function(){ //Set the new label value form.getComponent('txtFirst').labelEl.dom.innerHTML = 'Hello'; } }] }], items: [{ xtype: 'textfield', itemId: 'txtFirst', name : 'first', label: 'First name' }] }); } });
Hope this helps.Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
14 Jul 2011 7:54 PM #3
Thanks a lot for your reply , I got it.
-
14 Jul 2011 11:24 PM #4
You are welcome.
Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
5 Aug 2011 9:29 AM #5


Reply With Quote