In our application we have a textfield and a checkbox. By default textfield should be readonly. Whenever check box is checked, textfield should be editable.
We are able to do the above mentioned requirement. But we also have to show textfield in such a way that users should feel they can not edit it, when it is read only.
We used the below code for this:
{
xtype:'textfield',
id:'textfieldid',
readOnly:true,
fieldCls:'x-item-disabled'
...
}
{
xtype:'checkbox',
listeners:{
change:function(thisCmp,newValue,oldValue){
if(newValue==true){
Ext.getCmp('textfieldid').addCls('x-item-disabled');
} else {
Ext.getCmp('textfieldid').removeCls('x-item-disabled');
}
}
}
}
But some how i am not able to get it working.
Could anyone please suggest the way to solve it?
Actually I need to submit that field. If it is disabled, that field will not be submitted. So I tried with setting fieldCls dynamically.