0

不幸的是,我找不到任何有关通过 id 获取“Ext.tab.Panel”的有用信息。我将更具体地说明来源:

我正在定义一个要使用的面板:

Ext.define('MyMobileApp.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
id: 'mainTabPanel',
....

在此面板中包含的当前活动视图中,我创建了一个按钮并在其上放置了一个处理程序:

xtype: 'button',
text: 'Switch View',    
handler: function () {
    var main = Ext.getCmp('mainTabPanel'); //.getActiveTab();
    main.setActiveTab(Ext.getCmp('AnotherView'));
...

其中“AnotherView”是视图的 id,它也是面板的一部分。
但是在尝试“setActiveTab”时出现错误:

Uncaught TypeError: Object [object Object] has no method 'setActiveTab'

看起来 extjs 正在寻找一个对象,但无法序列化?

我想做的就是通过自定义按钮处理程序切换视图。

4

1 回答 1

1

问题在于,选项卡面板没有该功能'setActiveTab'

你必须'setActiveItem'改用。

Sencha Touch 2 Api:http ://docs.sencha.com/touch/2-1/#!/api/Ext.tab.Panel-method-setActiveItem

xtype: 'button',
text: 'Switch View',    
handler: function () {
    var main = Ext.getCmp('mainTabPanel'); //.getActiveTab();
    main.setActiveItem(Ext.getCmp('AnotherView'));
    //main.setActiveItem(1); //You can also set the new item with the index of it
    ...
于 2013-01-31T10:19:00.307 回答