Reputation: 1096
Today I was trying to set the active item on a tabpanel from a button inside a view and thought of share the code, so its already a solved question. You can see my answer below.
Upvotes: 3
Views: 5324
Reputation: 5883
(Changed to a community wiki answer to suit SO Q & A format)
The OP wrote:
All you need is to assign an id for the tabpanel like the following code:
Ext.define("appName.view.Main", { extend: 'Ext.tab.Panel', id: 'mainTabPanel',
Then use the following code to retrieve this tabpanel and set the active item
Ext.getCmp('mainTabPanel').setActiveItem(1);
Hope this will help someone
@Dawesi wrote:
just for anyone else looking at this, you can pass the index, the panel id or the panel object itself to set active item
@Proto Bassi wrote:
Instead of
Ext.getCmp()
you should useExt.Viewport.down()
as this will stop as soon as it finds a match.getCmp
will look through all items and that might take longer. And you should useitemId
instead ofid
.
Upvotes: 2