Changing TextField style dynamically in Extjs

10,823

Solution 1

1.First make sure to have an id for you item
2.Now try Ext.get('yourID').setStyle('margin-top','30px');
--This should work

Solution 2

If you're using ExtJs 4, don't assign style like this directly. Use setStyle method: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.Text-method-setFieldStyle

Share:
10,823
Dennis
Author by

Dennis

Updated on June 04, 2022

Comments

  • Dennis
    Dennis almost 2 years

    I'm trying to set the background-color and color of a TextField (to mask a password) on a checkbox click event. My best try:

    var hidePass = new Ext.form.Checkbox({
                xtype: 'checkbox',
                boxLabel: 'Hide Password',
                name: 'hidePass',
                handler: function (checkbox, checked) {
                    if (checked) {
                        pass1.fieldStyle = 'background-color: #ddd; background-image: none;';
                    }
                }
            });
    

    this code doesn't work. No errors are thrown. I'm not sure where to go from here. I've searched everywhere and can't find anything like this. I can't find any properties or methods to change the style that works.

  • Dennis
    Dennis about 10 years
    I'm hoping this is right, as I'm long past being able to test this as the right answer.