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?

1
  • 1
    There are various way I think you can achieve this. Could you first try SomeField.inputEl.addCls(). Commented Aug 7, 2012 at 14:10

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Never mind my edit, it was undefined because the field hadn't been rendered yet. inputEl works just fine, many thanks to yourself and Izhaki!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.