1. #1
    Ext JS Premium Member
    Join Date
    Feb 2009
    Posts
    443
    Vote Rating
    3
    Jangla is on a distinguished road

      0  

    Default Prevent setting readOnly on Trigger Field hiding trigger

    Prevent setting readOnly on Trigger Field hiding trigger


    Title says it all really. This was really easy to override in Ext 3 but no so much in Ext 4 as the updateLayout function is much more convoluted.

    So, is there a way in Ext 4 to prevent the trigger element from being set to invisible when clicking a trigger is calling readOnly = true on the field?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Something like this?

    Code:
    Ext.define('Ext.ux.CustomTrigger', {
        extend         : 'Ext.form.field.Trigger',
        alias          : 'widget.customtrigger',
    
        readOnly : true,
    
        getTriggerMarkup : function() {
            this.readOnly = false;
    
            var ret = this.callParent();
            
            this.readOnly = true;
    
            return ret;
        }
    });
    
    Ext.create('Ext.form.FormPanel', {
        title       : 'Form with TriggerField',
        bodyPadding : 5,
        width       : 350,
        renderTo    : Ext.getBody(),
        items       : [
            {
                xtype      : 'customtrigger',
                fieldLabel : 'Sample Trigger',
                emptyText  : 'click the trigger'
            }
        ]
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Ext JS Premium Member
    Join Date
    Feb 2009
    Posts
    443
    Vote Rating
    3
    Jangla is on a distinguished road

      0  

    Default


    Nope. Your code doesn't work for a couple of reasons:

    1. The trigger is created in a poor position - see screenshot
    2. Clicking the trigger doesn't change the readOnly status of the field - it's always read only.

    The requirement is to have a trigger field that, when user clicks it's trigger toggles from read only to writable and vice versa. The trigger should not vanish on making the field readOnly as is the default behaviour currently in Ext
    Attached Images

Thread Participants: 1