ExtJS4.1, when Filefield sets the default value to True, the button is grayed out, but if you call setdisabled to set it, the browse button is not grayed out, but it is really disabled. How to solve, can only start from the source code. The original source is not active on the browse button with a grayed out style, only when the default value is true to add. So we need to manually add CSS style to the source code.
The default source code is as follows:
Disableitems:function () {
var file = This.fileinputel;
if (file) {
file.dom.disabled = true;
}
this[' Buttonel-btnel '].dom.disabled = true;
onenable:function () {
var me = this;
Me.callparent ();
me.fileInputEl.dom.disabled = false;
this[' Buttonel-btnel '].dom.disabled = true;
},
Modify the method and the revised source code as follows:
Ext.override (ext.form.field.file,{
disableitems:function () {
var File = This.fileinputel;
if (file) {
file.dom.disabled = true;
}
this[' Buttonel '].addcls (' x-btn-disabled ');
this[' Buttonel-btnel '].dom.disabled = true;
onenable:function () {
var me = this;
Me.callparent ();
me.fileInputEl.dom.disabled = false;
this[' Buttonel '].removecls (' x-btn-disabled ');
this[' Buttonel-btnel '].dom.disabled = true;
}
};
After modification, the test screenshot is as follows.
Normal
Disabled after
When enabled