简体   繁体   English

通过ID的ExtJS getCmp Panel无法序列化吗?

[英]ExtJS getCmp Panel by id doesn't serialize?

unfortunately I wasn't able to find any useful info about getting 'Ext.tab.Panel' by id. 不幸的是,我无法找到有关通过ID获取“ Ext.tab.Panel”的任何有用信息。 I'll be more specific with a source: 我将更详细地说明一个来源:

I'm defining a panel to work with: 我正在定义要使用的面板:

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

In currently active view, which is contained in this panel I created a button and put a handler on it: 在此面板中包含的当前活动视图中,我创建了一个按钮并在其上放置了一个处理程序:

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

Where 'AnotherView' is id of a view which is also part of the panel. 其中“ AnotherView”是视图的ID,也是面板的一部分。
But i'm getting error when trying to 'setActiveTab': 但是尝试“ setActiveTab”时出现错误:

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

Looks like extjs is finding an object, but can't serialize? 看起来extjs正在找到对象,但是无法序列化?

All I want to do is switch views by custom buttons handlers. 我要做的就是通过自定义按钮处理程序切换视图。

The problem ist, that the Tab Panel doesn't have the function 'setActiveTab' 问题在于,“选项卡面板”没有功能'setActiveTab'

You have to use 'setActiveItem' instead. 您必须改为使用'setActiveItem'

Sencha Touch 2 Api: http://docs.sencha.com/touch/2-1/#!/api/Ext.tab.Panel-method-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
    ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM