View Full Version : How to disable the inputEl of a textfield in ExtJS?

31 Jan 2013, 4:08 AM
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.

1 Feb 2013, 2:45 PM
You need to access labelEl of the textfield and set the opacity on that element.
Here is the sample working 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



2 Feb 2013, 3:07 AM
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.