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"
});
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
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
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.
加载中,请稍侯......
精彩评论