View Full Version : add / change config items during runtime

12 May 2010, 8:12 AM

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:

MyContainer = Ext.extend(MyContainerUi, {
initComponent: function() {
MyFieldUi = Ext.override(Ext.form.TextArea, {

enableKeyEvents: true,
initComponent: function() {

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

12 May 2010, 9:46 AM
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.