Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8404079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:30:25+00:00 2026-06-09T22:30:25+00:00

When I set a form field into the disabled state using setDisabled or the

  • 0

When I set a form field into the disabled state using setDisabled or the disabled: true config, for example:

form.getComponent(1).setDisabled(true);

it makes the field unreadable due to the transparency. Is there a good way to improve the look and feel of my disabled fields?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:30:26+00:00Added an answer on June 9, 2026 at 10:30 pm

    We use an override on Ext.form.Field, which hides the triggers etc, and then we add a css class. We then style the component, because the disabled function of ExtJS is indeed not readable enough.

    Here is example code:

    var originalRender = Ext.form.Field.prototype.onRender;
    Ext.override(Ext.form.Field, {
        UxReadOnly: false,
        UxDisplayOnly: function (displayOnly, cls) {
            // If no parameter, assume true
            var displayOnly = (displayOnly === false) ? false : true;
    
    
            if (displayOnly) {
                // If a class name is passed in, use that, otherwise use the default one.
                // The classes are defined in displayOnly.html for this example 
                var cls = (cls) ? cls : 'x-form-display-only-field';
    
                // Add or remove the class
                this.addClass(cls);
    
                // Set the underlying DOM element's readOnly attribute
                this.setReadOnly(displayOnly);
                this.editable = false;
    
                // Get this field's xtype (ie what kind of field is it?)
                var xType = this.getXType();
    
                if (xType == 'combo' | xType == 'combobox' | xType == 'Ext.ux.Combo' | xType == 'Ext.ux.ComboSearch') {
                    this.addClass('x-form-display-only-combo');
                    this.hideTrigger = true;
                    this.on('expand', function (field) {
                        if (field.hideTrigger)
                            field.collapse();
                    });
                }
                else if (xType == 'datefield') {
                    this.addClass('x-form-display-only-datefield');
                    this.hideTrigger = true;
                    this.on('expand', function () {
                        if (this.hideTrigger)
                            this.collapse();
                    });
                    this.editable = false;
                } //elseif for each component u want readonly enabled
                else {
                    this.addClass('x-form-display-only-other');
                }
    
                // For fields that have triggers (eg date,time,dateTime), 
                // show/hide the trigger
                if (this.trigger) {
                    this.trigger.setDisplayed(!displayOnly);
                }
    
            } else {
                this.UxFullField(cls);
            }
        },
        afterRender: function () {
            var me = this;
            me.UxDisplayOnly(me.UxReadOnly, 'x-form-display-only-field');
            this.callParent(arguments);
        },
        UxFullField: function (cls) {
            // If a class name is passed in, use that, otherwise use the default one.
            // The classes are defined in displayOnly.html for this example 
            var cls = (cls) ? cls : 'x-form-display-only-field';
    
            this.removeCls(cls);
    
            // Set the underlying DOM element's readOnly attribute
            this.setReadOnly(false);
            this.editable = true;
    
            // Get this field's xtype (ie what kind of field is it?)
            var xType = this.getXType();
    
            if (xType == 'combo' | xType == 'combobox' | xType == 'Ext.ux.Combo' | xType == 'Ext.ux.ComboSearch') {
                this.removeCls('x-form-display-only-combo');
                this.setHideTrigger(false);
            }
            else if (xType == 'datefield') {
                this.removeCls('x-form-display-only-datefield');
                this.setHideTrigger(false);
                this.editable = true;
            }//elseif for each component u want readonly enabled
            else {
                this.removeCls('x-form-display-only-other');
            }
    
            // For fields that have triggers (eg date,time,dateTime), 
            // show/hide the trigger
            if (this.trigger) {
                this.setHideTrigger(false);
            }
        }
    });
    

    With css you hide stuff like borders etc…

    .x-form-display-only-field{}
    
    .x-form-display-only-other input, .x-form-display-only-other select { background: transparent !important; border: 1px solid transparent !important; cursor: pointer; cursor: default; font-weight: bold; background-image: none !important; background-color: transparent !important; }
    .x-form-display-only-combo input, .x-form-display-only-combo select { background: transparent !important; border: 1px solid transparent !important; cursor: pointer; cursor: default; font-weight: bold; background-image: none !important; background-color: transparent !important; }
    .x-form-display-only-datefield input, .x-form-display-only-datefield select { background: transparent !important; border: 1px solid transparent !important; cursor: pointer; cursor: default; font-weight: bold; background-image: none !important; background-color: transparent !important; }
    .x-form-display-only-file input, .x-form-display-only-file select { background: transparent !important; border: 1px solid transparent !important; cursor: pointer; cursor: default; font-weight: bold; background-image: none !important; background-color: transparent !important; }
    
    .x-form-display-only-checkbox { }
    .x-form-display-only-radiogroup { }
    

    Now you can add your field the following way:

    Ext.create('Ext.form.field.Text', {
         name: 'example',
         UxReadOnly: true
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good evening, I'd like to set up a form with a single field (name),
how do I set the value of a field element after a form has
I need to set the value of a field in a form via JavaScript.
I have a bilingual website The value of a form field is set to
I am trying to scrape form field IDs using Beautiful Soup like this for
I have an add form that allows me to add the specific field into
I have some markup for a set of fields within a form: <ul> <li>
In iTextSharp is there a way to set ALL fields on a form to
Is there any way to set the HTTP header fields of a HTML form
I'm trying to set form validation with cyrillic alphabet but I get We're sorry,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.