单击EXTJS中选项卡面板的侦听器
我在extjs中使用一个选项卡面板。我想在单击选项卡时显示警报。但我不知道怎么做 这就是我现在所做的:单击EXTJS中选项卡面板的侦听器,extjs,tabs,listener,Extjs,Tabs,Listener,我在extjs中使用一个选项卡面板。我想在单击选项卡时显示警报。但我不知道怎么做 这就是我现在所做的: { xtype: 'tabpanel', activeTab: 0, region: 'center', items: [ { xtype: 'panel',
{
xtype: 'tabpanel',
activeTab: 0,
region: 'center',
items: [
{
xtype: 'panel',
title: 'All',
items: [grid]
},
{
xtype: 'panel',
title: 'Closed'
},
{
xtype: 'panel',
title: 'Open'
}
],
listeners: {
click: function () {
alert('test');
}
}
}
单击该选项卡时,如何显示全部、关闭或打开?在
TabPanel
中没有选项卡单击事件,但是您可以绑定到每个选项卡上的单击事件中:
Ext.createWidget('tabpanel', {
items: [...],
listeners: {
render: function() {
this.items.each(function(i){
i.tab.on('click', function(){
alert(i.title);
});
});
}
}
});
注意:这是基于extjs4的代码。我通过使用
tabchange
事件来实现这一点。在下面的示例中,我使用了newCard.xtype
属性,其中xtype的值(即task archive
)只是我的面板,带有控件和相应的xtype属性
Ext.define('ComplexBrigade.controller.taskArchive.TaskArchive', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'#tabWorks': {
tabchange: this.doTest
}
});
},
doTest: function ( tabPanel, newCard, oldCard, eOpts) {
switch (newCard.xtype) {
case "task-archive":
console.log("task-archive");
break;
case "task-creation":
console.log("task-creation");
break;
}
}
});