Murdock
Murdock

Reputation: 123

Change fieldCls at runtime

I am trying to change the css of a text field at runtime, using ExtJs 4.1.

I have set the initial css using fieldCls: '' , which works fine.

However, using addCls and removeCls have nothing to do with fieldCls, and will only change the root element's css, and not the field.

What's the correct way to change the css class of a text field at runtime?

Thanks

EDIT: Perhaps it's time for some code:

        this.form.getComponent('content').on('writeablechange', function(field, Read, eOpts){
            if (Read == true){
              field.inputEl.addCls('x-form-field-readonly');

            }

            else if (Read == false){

            }

        }, this);

Let's ignore the fact for a second that I can't get a read only field to update css on it's own using any of the config properties I've come across.

This code executes, and displays alerts on each of the cases if i put them in.

I've tried field.inputEl, and I get undefined at runtime. Any ideas?

Upvotes: 0

Views: 1511

Answers (1)

Alex Tokarev
Alex Tokarev

Reputation: 4861

If you want to set styles on a field, you can use field.setFieldStyle(). Otherwise, field.inputEl is the element you need.

Upvotes: 2

Related Questions