0

ユーザーがグリッド上の行を選択したことに反応したいときは、これを使用します。

var grid = new Ext.grid.GridPanel({
    region: 'center',
    ...
});
grid.getSelectionModel().on('rowselect', function(sm, index, rec){
    changeMenuItemInfoArea(menuItemApplication, 'you are on row with index ' + index)
});   

タブに同じ機能を追加するにはどうすればよいですか? このようなもの:

var modules_info_panel = new Ext.TabPanel({
    activeTab: 0,
    region: 'center',
    defaults:{autoScroll:true},
    listeners: {
        'tabclick': function(tabpanel, index) {
            changeMenuItemInfoArea(menuItemModules,'you clicked the tab with index ' + index);
        }
    },
    items:[{
            title: 'Section 1',
            html: 'test'
        },{
            title: 'Section 2',
            html: 'test'
        },{
            title: 'Section 3',
            html: 'test'
        }]
});
modules_info_panel.getSelectionModel().on('tabselect', function(sm, index, rec){
    changeMenuItemInfoArea(menuItemModules, 'you are on tab with index ' + index)
});

補遺

ありがとう@timdev、それは機能します。これがどのタブであるかを識別する方法です(単純にid、グリッドで行のインデックスを取得できたので、タブのインデックスを取得できませんでした):

var modules_info_panel = new Ext.TabPanel({
    activeTab: 0,
    region: 'center',
    defaults:{autoScroll:true},
    items:[{
            id: 'section1',
            title: 'Section 1',
            html: 'test'
        },{
            id: 'section2',
            title: 'Section 2',
            html: 'test'
        },{
            id: 'section3',
            title: 'Section 3',
            html: 'test'
        }]
});

modules_info_panel.items.each(function(tab){
    tab.on('activate',function(panel){
        changeMenuItemInfoArea(menuItemModules, 'you opened the "' + panel.id + '" tab');
    });
});

replaceComponentContent(regionContent, modules_info_panel);

hideComponent(regionHelp);
4

2 に答える 2

1

TabPanelの「beforetabchange」イベントを使用することもできます。

tabs.on('beforetabchange', function(tabPanel, newItem, currentItem) { ... }, this);
于 2010-12-03T17:45:31.697 に答える
1

あなたは近くにいます。

tabpanel 内の個々のパネルはactivate、アクティブ化されるとイベントを発生させます。

listeners構成時に、構成キー を使用して、TabPanel の各項目にハンドラーをアタッチします。

または、次のように、リスナーをアタッチしているすべてのタブを反復処理することもできます。

modules_info_panel.items.each(function(tab){
    tab.on('activate',function(panel){ ... });
}
于 2010-12-02T18:24:22.053 に答える