6

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

I am using tabpanel in my application.

kdopen
  • 8,032
  • 7
  • 44
  • 52
user386430
  • 4,837
  • 13
  • 41
  • 45
  • 2
    Could you provide us what you have already tried? – DawidPi Oct 14 '15 at 18:41
  • 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. – kdopen Oct 16 '15 at 19:33
  • Also, with these edits, the body is little more than a restatement of the title. Some more details would be useful – kdopen Oct 16 '15 at 19:34

4 Answers4

7
var tabpanel = Ext.ComponentQuery.query('mainViewport #mainTabPanel'); //use your item Id / reference here
var activeTab = tabpanel.getActiveTab();
var activeTabIndex = tabpanel.items.indexOf(activeTab);
Mohit Saxena
  • 1,439
  • 1
  • 12
  • 21
3

I had to use:

tabpanel.getActiveItem();

Was getting this error on getActiveTab:

getActiveTab is not a function

IAmCoder
  • 3,179
  • 2
  • 27
  • 49
3
var activeTab = tabPanel.getActiveTab();
var currentStep = tabPanel.items.indexOf(activeTab);
Martin Evans
  • 45,791
  • 17
  • 81
  • 97
RMarts
  • 31
  • 1
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;
}