1. #1
    Ext User
    Join Date
    Mar 2010
    Posts
    15
    Vote Rating
    0
    rhenkel is on a distinguished road

      0  

    Default add / change config items during runtime

    add / change config items during runtime


    Hello,

    I would like to add {enableKeyEvent:true} to a Textarea during runtime, because it is not available by Designer's Component Config (yet ?).

    That leads me to the general question how to do this and similar actions with arbitrary components.

    1. I could insert the config params into MyContainer.ui.js - but it will be overwritten every time I export it.
    2. I tried it successfully whith th following code in MyContainer.js:

    Code:
    MyContainer = Ext.extend(MyContainerUi, {
        initComponent: function() {
            MyContainer.superclass.initComponent.call(this);
            MyFieldUi = Ext.override(Ext.form.TextArea, {
    
                enableKeyEvents: true,
                initComponent: function() {
                    MyFieldUi.superclass.initComponent.call(this);
                }
            });
    
            this.textfld.on('keypress', this.onkeypress, this);
        },
        onkeypress: function(fld, e) {
            var k = e.getKey();
            alert("You just presssed "+k+", but why?");
        }
    });

    However, this will affect the whole class, I think, but not only the particular object instance.

    Please help me to figure out how to get it.

    Thanks in advance

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,308
    Vote Rating
    125
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Ext.override will affect all instances of that class as you stated above.

    Also, currently you are running this within the initComponent portion of the code which will run everytime. You only need to run this once.

    You can add the enableKeyEvents within your subclass of the Ui class. (That doesn't get overwritten.)

    We'll get the enableKeyEvents configuration added in a nearby release.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

Thread Participants: 1