0

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?

4

1 回答 1

2

如果要在字段上设置样式,可以使用 field.setFieldStyle()。否则, field.inputEl 是您需要的元素。

于 2012-08-07T16:43:40.457 回答