Reputation: 875
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 as ReadOnly
.
Is there a way to disable only the inputEl
of a textfield component?
Thanks for your help.
Upvotes: 3
Views: 6097
Reputation: 11
What about this one?
items: [{
xtype: 'textfield',
name: 'item',
itemId: 'item',
readOnly: true,
listeners:{
afterrender: function(f){
c.inputEl.addCls('x-item-disabled');
}
}]
You could even make it change dicamically if you include an if befor apply the class
Upvotes: 1
Reputation: 875
I have got another answer from the Sencha forum (I thought it may be interesting to post it here also) Solution:
Use the setOpacity method
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); });
Upvotes: 0