当我想对用户在网格上选择一行做出反应时,我使用这个:
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);