简体   繁体   English

访问extjs4.2中不同选项卡的值

[英]Access the values of different tabs in extjs4.2

I have created a tab panel in extjs4.2 , and what i'm trying to do is access the values in the form of a tab while being in the other tab. 我已经在extjs4.2中创建了一个选项卡面板,而我想做的就是在另一个选项卡中同时以选项卡的形式访问值。 For example the user is on tab A and have access to the values in tab B. How can access the other tab? 例如,用户位于选项卡A上,并有权访问选项卡B中的值。如何访问另一个选项卡?

tabPanel = Ext.create('Ext.tab.Panel', {
        region: 'center',
        activeTab: 0,
        autoScroll: true,
        items: [
                {   
                    id:"panel_A",
                    title: "${tr.A}",
                    html: "<iframe src= '"+A_url +"' width='100%' height='100%' id='frm_A' name='frm_A' frameborder=0 />",
                },{
                    id:"panel_B",
                    title: "${tr.B}",
                    //disabled:tabs_status,
                    //hidden:hidden,
                    html: "<iframe src='"+B_url +"'  width='100%' height='100%' id='frm_B' name='frm_B' frameborder=0 />",
                }]
        });


    viewport = new Ext.Viewport({
        layout:'border',
        items:[tabPanel]
    });

In this part on a click of a button i'm able to access the current frame. 在这部分中,单击按钮就可以访问当前框架。

new Ext.Toolbar.Button({
                        id:"btn_show",
                        text: "${tr.Show}",
                        tooltip: "${tr.Show}",
                        handler: function(){view(frmid);}
                    }),

     function view(frmid) {

             var A_key =   window.frames[frmid].RECORD.getKey();
            /* var B_key = window.frames[...].RECORD.getField("HISTORY").getRealValue();*/



        }

To select Ext.ComponentView you can use Ext.ComponentQuery . 要选择Ext.ComponentView ,可以使用Ext.ComponentQuery

Provides searching of Components within Ext.ComponentManager (globally) or a specific Ext.container.Container on the document with a similar syntax to a CSS selector. 使用与CSS选择器类似的语法在Ext.ComponentManager中(全局)或文档中特定的Ext.container.Container中搜索组件。 Returns Array of matching Components, or empty Array. 返回匹配组件的数组,或者为空数组。

More about selectors for DOM Elements and ExtJS Components in this answer . 此答案中,有关DOM元素和ExtJS组件选择器的更多信息。

Basic example of how you can access another tab of a tabpanel : 如何访问标签tabpanel另一个标签的基本示例:

Working fiddle 工作提琴

// If you button is child / parent button of a tabpanel its efficient to use down() / up() methods
// Since we get button component reference as listener function arguments we can select parent tabpanel component,
// and after it select child component panel (because panel is default xtype for tabpanel items and textfield after it
panelBTextFieldValue = button.up('tabpanel').down('panel[id=panel_B] textfield[name=panel_B_text_field]').getValue();

// If your button is somewhere else you can use Ext.ComponentQuery.query()
panelBTextFieldValue = Ext.ComponentQuery.query('tabpanel[id=myPanel] panel[id=panel_B] textfield[name=panel_B_text_field]').getValue();

// or just if selector textfield[name=panel_B_text_field] specific enought for whole your application
panelBTextFieldValue = Ext.ComponentQuery.query('textfield[name=panel_B_text_field]').getValue();

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

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