Extjs 无法获取选项卡面板的对象

Extjs 无法获取选项卡面板的对象,extjs,extjs4,Extjs,Extjs4,在边界布局的中心区域有一个网格。在网格中单击特定项时,我需要更改中心区域以显示选项卡面板。获取tabpanel对象时遇到问题 在网格侦听器的ctrlpanel文件中,我使用componentQuery获取tabpanel'ccmain'对象。它返回undefined 我曾使用componentQuery在centerpanel文件Layouts out center region中成功获取“ccmain”,但当我将此代码移动到ctrlpanel文件时,centerpanel中的一个项目失败了。C

在边界布局的中心区域有一个网格。在网格中单击特定项时,我需要更改中心区域以显示选项卡面板。获取tabpanel对象时遇到问题

在网格侦听器的ctrlpanel文件中,我使用componentQuery获取tabpanel'ccmain'对象。它返回undefined

我曾使用componentQuery在centerpanel文件Layouts out center region中成功获取“ccmain”,但当我将此代码移动到ctrlpanel文件时,centerpanel中的一个项目失败了。ComponentQuery不再返回选项卡面板“ccmain”。ComponentQuery不会返回中心面板或视口。我尝试使用centerpanel或viewport.down查找“ccmain”,但也返回未定义。如果您能告诉我如何获得标签面板或我做错了什么,我将不胜感激。谢谢你抽出时间

ctrlPanel.js

Ext.define('ServcSol.view.CtrlPanel',{
extend: 'Ext.Panel',

alias: 'widget.ctrlPanel',
xtype: 'ctrlPanel',
itemId: 'ctrlPanel',

requires:[
    'ServcSol.store.FacilityStore'
    ],

initComponent: function () {  

var me = this;

Ext.applyIf(me, {

items: [ 
{
  xtype: 'panel',
  height: 750,
  title: 'Control Panel',
  items: [
  {
   xtype: 'gridpanel',
   padding: '20 20 5 20',
   store: 'WorkHistoryStore',
   height: 590,
   width: '100%',
   border: true,
   columns: [
   {
     width: 110,
     dataIndex: 'wrkhistDate',
     text: 'Due Date'
   },
   {
     width: 100,
     dataIndex: 'wrkType',
     text: 'Work Type'
   }
 ], 
 listeners : {
   itemclick: function(dv, record, item, index, e) 
   {
     if(record.get('wrkType') == 'Test')
         {                   
           var tabPanel = Ext.ComponentQuery.query('ccmain')[0];
           console.log('tabPanel is: ', tabPanel);
           var tabIndex = tabPanel.items.findIndex('id', 'hazard');
           var center = Ext.ComponentQuery.query('centerpanel')[0];
           center.getLayout().setActiveTab(tabIndex);
     }
ccmain.js

Ext.define('ServcSol.view.ccMain', {
extend: 'Ext.tab.Panel',
itemId: 'ccmain',
alias: 'widget.ccmain',
xtype: 'ccmain',

initComponent: function () {

var me = this;

Ext.applyIf(me, {
items: [
      {
        xtype: 'facility'
      },
      {
        xtype: 'hazListing'
      },
      {
        xtype: 'hazard'
      }, 
      {
        xtype: 'testFormRP'
      },
      {
        xtype: 'testFormDC'
      } 
       ]
    });      
  this.callParent(arguments);
  }
 });

原因之一可能是ccmain没有实例化,因为ComponentQuery.query只能找到实例化的组件。然后,即使找到ccmain,也不能以这种方式设置其活动项。最简单的方法是分配选项卡ItemId,然后调用:


你的代码没有意义。您正试图将活动组件设置为字符串。很抱歉,键入错误。由于componentQuery未返回“ccmain”,因此代码未到达该点。编辑了这篇文章。
tabPanel.setActiveTab(itemIdOfTheTab)