not sure that that is a good title …
I can get code behind a button to:
TabBar.activeTab.setTitle("New Tab");
but I need to do something like:
TabBar.activeTab.items = { title: "New Tab"
};
so I can eventually automate several tab properties in a loop:
TabBar.activeTab.items = { [key]: [value]
};
Am I correct in thinking config and items can only be used on construct()? Is there a way of doing the above? tia.
It depends on the implementation of the component and config property in question whether it can simply be set or requires a method call to be applied.
You are correct that in ExtJs many config properties are interpreted at construction time. Some are interpreted at render time. Once an
Ext.Componentis rendered almost all properties require an explicit method call to be applied correctly.In general, I recommend to always use a method call to change a property after construction time if available in order to not break the inner workings of the component. If you look at the implementation of
Ext.panel.Panel#setTitleyou can see that there is a lot of stuff going on under the hood, e.g. event firing, etc.ExtJs 4 configuration
Ext 4 introduced an explicit ‘config’ mechanism that might serve your purpose. However, my understanding is that most ExtJs components are not (yet?) using it.
Check out ‘2. Configuration’ in the ExtJs Class System Guide
Create objects from xtype/config literals
If you want to add new components to a container (e.g. tabs to a tab panel) it would be rather easy to accomplish.
Use
Ext.ComponentManager#create(see [docs][2]) to create an actual component object/instance from your config literal.Ext.container.Container#addactually calls this method internally, so you can simply pass config objects to theaddmethod.If you want to remove or add tabs to a panel, there is now way around calling the proper methods.
applyConfig()
Of course you could always implement your own
applyConfigmethod that supports changing certain component configuration properties at runtime by ‘translating’ the config into the proper method calls.