[英]click listener for tab panel in EXTJS
i use a tab panel in extjs. 我在extjs中使用选项卡面板。 I want to display an alert when clicked on a tab.
我想在单击选项卡时显示警告。 But i am not sure how.
但我不确定如何。
This is what i do now: 这就是我现在所做的:
{
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');
}
}
}
How can is display All, Closed or Open when there is clicked on that tab? 单击该选项卡时,如何显示全部,关闭或打开?
There is no event for tab click in TabPanel
, however you can bind into click event on each tab: TabPanel
没有选项卡单击的事件,但您可以在每个选项卡上绑定到单击事件:
Ext.createWidget('tabpanel', {
items: [...],
listeners: {
render: function() {
this.items.each(function(i){
i.tab.on('click', function(){
alert(i.title);
});
});
}
}
});
Notice: this is ExtJS 4 based code. 注意:这是基于ExtJS 4的代码。
I manage to do this by using tabchange
event. 我设法通过使用
tabchange
事件来做到这一点。 In example below I used newCard.xtype
property where value of xtype (ie task-archive
) is just my panel with controls and corresponding xtype property. 在下面的示例中,我使用了
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;
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.