PDA

View Full Version : ExtJS 4.1.1a show/hide enable/disable form field dynamically



cms143
10 Oct 2012, 8:38 PM
Hello,

I am trying to show/hide and enable/disable a form field dynamically using the latest version of ExtJS 4.1.1a, and I am able to show or hide the field but when I try to disable or enable the field I get the following error in the web browser:

TypeError: Object [object Object] has no method 'disable'


Here is the javascript code I am trying to use:


var fixedField = field.getEl().up('table.x-anchor-form-item').down('.show_this_field');

fixedField.disable();

I am executing that line of javascript in a radio group change listener, which is where the variable field is coming from above.

Showing/Hiding the field works when I do this:


fixedField.show();


But I cannot disable or enable the field.... how can I disable or enable the field?


The challenge here is that I am not using an id on the form field that needs to be enabled because there is multiple fields with the same element on the page so I am trying to select the form field by it's css class that I added to the cls attribute.

fschaeffer
10 Oct 2012, 8:54 PM
Hi,

you are using field.getEl() which returns an DOM Element, so I'm not quite sure what you are trying to adress by your up / down - paths ...

Most likely you will end up having a DOM Element (which has a show()-method but no enable() / disable() - method).

Usually you should just use the field.up() / field.down() methods to get ExtJS Components as reference, as these components have the respective disable() / enable() - methods.

To adress the field you could leverage componentQuery and give the outer component a class to limit the query to just this field. Without your code it is impossible to know what kind of your initial "field" is ...

HTH
Florian