簡體   English   中英

單擊EXTJS中的選項卡面板的監聽器

[英]click listener for tab panel in EXTJS

我在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);
                });
            });
        }
    }
});

注意:這是基於ExtJS 4的代碼。

我設法通過使用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;
        }
    }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM