1. #1
    Sencha User
    Join Date
    Jul 2008
    Posts
    51
    Vote Rating
    0
    howe is on a distinguished road

      0  

    Default Changing fieldLabel dinamically ?

    Changing fieldLabel dinamically ?


    Hello,

    How do I change a field's fieldLabel dinamically, i.e. after the field has been rendered, in ExtJS 4.0 ?

    Thanks,
    Howe

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Posts
    78
    Vote Rating
    1
    kskrumpet is on a distinguished road

      0  

    Default


    I suspect you'll have to doLayout on the form after changing the fieldLabel attribute - I can't see any easy way to get the dom element to force the change.

    But why would you do this?

    Rich

  3. #3
    Sencha User
    Join Date
    Jul 2008
    Posts
    51
    Vote Rating
    0
    howe is on a distinguished road

      0  

    Default


    I was expecting to have a less obvious (and resource-hungry) way. Need to do it because a I need to change a field's label, of course

    If anyone knows a better way, please tell me.

    Thanks.

  4. #4
    Sencha User
    Join Date
    Apr 2010
    Posts
    78
    Vote Rating
    1
    kskrumpet is on a distinguished road

      0  

    Default


    Sounds like you're trying to repurpose an existing form to take input for several different reasons. Sounds dodgy to me.

    Rich

  5. #5
    Sencha User
    Join Date
    Jul 2008
    Posts
    51
    Vote Rating
    0
    howe is on a distinguished road

      0  

    Default


    Quote Originally Posted by kskrumpet View Post
    Sounds like you're trying to repurpose an existing form to take input for several different reasons. Sounds dodgy to me.

    Rich
    Not really, just translating some labels.

    Howe

  6. #6
    Sencha User
    Join Date
    Apr 2010
    Posts
    78
    Vote Rating
    1
    kskrumpet is on a distinguished road

      0  

    Default


    May I suggest you have a locale file containing all the correct language strings as "variables" and use those for your labels - then your server can push the right locale file in response to the original request, or if someone wants to change the language on the fly you dynamically load the new locale and redraw the whole app?

    -- edit --
    It's late and I didn't think this one through - the on the fly bit wouldn't work 'cos changing the locale wouldn't change all the data in the Ext object structures...

  7. #7
    Sencha User
    Join Date
    Jul 2008
    Posts
    51
    Vote Rating
    0
    howe is on a distinguished road

      0  

    Default


    That's kind of what I already do, I was just trying to avoid to redraw the form.

    Thanks !
    Howe

  8. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    If you really wanted to, you could iterate through each item and then query down to the label and update that element. Make sure you change the fieldLabel property also.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 2