TheHorse
TheHorse

Reputation: 2797

ExtJS 3. Append configs dynamically

Is there any way to apend some configs (object properties) to created extobject.

var thePanel = new Ext.Panel({
   border: false
});

thePanel.addpendConfigs({               //How to?
   height: 40,
   region: "north"
});

Upvotes: 0

Views: 747

Answers (3)

Alex
Alex

Reputation: 5724

As far as I know, once the object has been instantiated, you cannot simply whack new config options into it. It bubbles too much ( eg, say for example you want to overwrite the "items" array, this affects quite a bit of your actual object ).

Generally ExtJs has a method to do what you want to do however.

Upvotes: 0

Varun Achar
Varun Achar

Reputation: 15109

Use the Ext.applyIf. From the docs

Copies all the properties of config to obj if they don't already exist.

Here's the definition:

applyIf( Object obj, Object config ) : Object

Otherwise use the Ext.apply

Copies all the properties of config to obj.

Definition:

apply( Object obj, Object config, Object defaults ) : Object

Upvotes: 1

nscrob
nscrob

Reputation: 4493

i'm guessing from setting the region north that you wan't to add the panel to a container with border layout ... I believe you can do something like

thePanel.setHeight(40);
thePanel.region = 'north';

container.add(thePanel);
container.doLayout();

dolayout method should force the recalculation of the layout on all the components ...

Edit:

For the universal solution check Ext.apply

var config = {
   height: 40,
   region: "north"
}

Ext.apply(thePanel,config);

But i think you still need to force the layout recalculation like above

Upvotes: 2

Related Questions