How can I get the active tab index in tab panel?
Asked Answered
T

4

6

How can I get the active or selected tab index in tab panel in sencha touch?

I am using tabpanel in my application.

Taneshatang answered 14/10, 2015 at 17:43 Comment(3)
Could you provide us what you have already tried?Supinator
Removed the tag from the title and made it a question; removed duplicate sentence; removed 'thank you' fluff. Still needs examples of what the OP has tried, and how it fails them.Rochus
Also, with these edits, the body is little more than a restatement of the title. Some more details would be usefulRochus
I
7
var tabpanel = Ext.ComponentQuery.query('mainViewport #mainTabPanel'); //use your item Id / reference here
var activeTab = tabpanel.getActiveTab();
var activeTabIndex = tabpanel.items.indexOf(activeTab);
Inarch answered 15/10, 2015 at 9:56 Comment(0)
L
3

I had to use:

tabpanel.getActiveItem();

Was getting this error on getActiveTab:

getActiveTab is not a function

Langrage answered 7/5, 2017 at 20:51 Comment(0)
F
3
var activeTab = tabPanel.getActiveTab();
var currentStep = tabPanel.items.indexOf(activeTab);
Flamboyant answered 4/11, 2017 at 12:40 Comment(0)
V
0

This is correct code:

getTabIndex: function(tab) {
    var index = 0;

    tab.up('#mainTabPanel').getItems().each(function(item) {
        if (tab === item) {
            return false;
        }

        if (item.tab) {
            index++;
        }
    });

    return index;
}
Vedavedalia answered 6/5, 2016 at 10:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.