ExtJS Filefield set the disabled to true after the button is not grayed out

Source: Internet
Author: User

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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.