-
31 Jan 2013 4:08 AM #1
Answered: How to disable the inputEl of a textfield in ExtJS?
Answered: How to disable the inputEl of a textfield in ExtJS?
I am working with ExtJS and I have a textfield component. I would like to disable only the inputEl of a textfield component (not the label).
If I use the setDisabled() method of the textfield, then it sets disabled the inputEl but also the label.
I have used also the setReadOnly() method, but it does not grey out the inputEl, only set asReadOnly.
Is there a way to disable only the inputEl of a textfield component?
Thanks for your help.
-
Best Answer Posted by sriram139
You need to access labelEl of the textfield and set the opacity on that element.
Here is the sample working code:
Thanks,Code:Ext.onReady(function () { var panel =Ext.create('Ext.form.Panel', { title: 'Basic Form', renderTo: Ext.getBody(), bodyPadding: 5, width: 350, items: [{ xtype: 'textfield', fieldLabel: 'Field', name: 'theField', disabled: true }] }); panel.down('[xtype=textfield]').labelEl.setOpacity(1); });
Sriram
-
1 Feb 2013 2:45 PM #2
Use setOpacity() on labelEl
Use setOpacity() on labelEl
You need to access labelEl of the textfield and set the opacity on that element.
Here is the sample working code:
Thanks,Code:Ext.onReady(function () { var panel =Ext.create('Ext.form.Panel', { title: 'Basic Form', renderTo: Ext.getBody(), bodyPadding: 5, width: 350, items: [{ xtype: 'textfield', fieldLabel: 'Field', name: 'theField', disabled: true }] }); panel.down('[xtype=textfield]').labelEl.setOpacity(1); });
Sriram
-
2 Feb 2013 3:07 AM #3
My approach was to create a custom class which is doing the same, setting the opacity. But your solution is much better.
Thank you Sriam.


Reply With Quote