21 February 2011

Set allowBlank dynamically in extjs

What to do if you want  set allowBlank dynamically ?
 In function where your logic make decision you just write this line

myField.allowBlank = true;

and that's it.

If you function dosen't include update of display specific field then add follow line
that will force field to update
(in  some cases you needed in some cases you dont needed (then you see error that value is not defined))

In case if you  have defined field inside form and for any reason you have issues with access to it.
Then .. i have good and bad news for you

Bad news .... you need move your fields out from form (from form looks cool :) ) and put before form is defined Good news .... it makes code more readable and easier to maintain and reuse

this.myForm = new Ext.form.FormPanel({
 ... settings like defaultType: 'textfield', and etc. ...
items: [

Source: www.extensions.extjs.com