Results 1 to 5 of 5

Thread: Dynamically Changing the Form label

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Location
    Coimbatore,India
    Posts
    14
    Vote Rating
    0
      0  

    Question 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

  2. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Vote Rating
    24
      0  

    Default

    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.

    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'
                }]
            });
        }
        
    });
    What I do in this example is take the wanted Field component from the form and then change the innerHTML of the labelEl.

    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  3. #3
    Sencha User
    Join Date
    Jun 2011
    Location
    Coimbatore,India
    Posts
    14
    Vote Rating
    0
      0  

    Talking

    Thanks a lot for your reply , I got it.

  4. #4
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Vote Rating
    24
      0  

    Default

    You are welcome.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  5. #5
    Sencha User
    Join Date
    Aug 2009
    Posts
    96
    Vote Rating
    1
      0  

    Default

    Why no "setLabel" ?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •