Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
单击EXTJS中选项卡面板的侦听器_Extjs_Tabs_Listener - Fatal编程技术网

单击EXTJS中选项卡面板的侦听器

单击EXTJS中选项卡面板的侦听器,extjs,tabs,listener,Extjs,Tabs,Listener,我在extjs中使用一个选项卡面板。我想在单击选项卡时显示警报。但我不知道怎么做 这就是我现在所做的: { xtype: 'tabpanel', activeTab: 0, region: 'center', items: [ { xtype: 'panel',

我在extjs中使用一个选项卡面板。我想在单击选项卡时显示警报。但我不知道怎么做

这就是我现在所做的:

{
                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;
        }
    }
});