EXTJS OnClick 选项卡事件

发布于 2024-10-08 15:50:04 字数 433 浏览 1 评论 0原文

有没有办法将 OnClick 事件附加到 EXTJS 中的选项卡开关?

我把网格做成这样:

var simple = new Ext.FormPanel({
    标签宽度: '100%',
    边框:假,
    宽度:'100%',
            风格: 
            {
                高度:'291px'
            },
    项目: {
        xtype: '标签面板',
        活动选项卡:0,
        //labelWidth: 75, // 这里的标签设置级联,除非被覆盖
        项目:[{
        url:'保存表单.php',
        标题:“选项卡 1”,
  ...

谢谢!

Is there a way to attach an OnClick event to a tab switch in EXTJS?

I make the grid like this:

var simple = new Ext.FormPanel({
    labelWidth: '100%',
    border:false,
    width: '100%',
            style: 
            {
                height: '291px'
            },
    items: {
        xtype: 'tabpanel',
        activeTab: 0,
        //labelWidth: 75, // label settings here cascade unless overridden
        items:[{
        url:'save-form.php',
        title: 'Tab 1',
  ...

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你的呼吸 2024-10-15 15:50:04

在定义选项卡后,我添加了一个侦听器,如下所示:

//define all tabs, and after the ] from the tab panel JSON: 
listeners: {
    'tabchange': function(tabPanel, tab) {
        alert("tab changed");
    }
}

这仅在选项卡更改时发出警报,这足以满足我的目的。我不确定如何找出哪个选项卡是当前选项卡。

希望这对将来的人有帮助。

I added in a listener after the tabs were defined like this:

//define all tabs, and after the ] from the tab panel JSON: 
listeners: {
    'tabchange': function(tabPanel, tab) {
        alert("tab changed");
    }
}

This just alerts when the tab changed, which is sufficient for my purposes. I'm not sure though how to find out which tab is the current tab.

Hope this helps someone in the future.

や三分注定 2024-10-15 15:50:04

当活动选项卡更改时,会触发 tabchange 事件:http://www .sencha.com/learn/Ext_FAQ_TabPanel

There is a tabchange event that fires when the active tab changes: http://www.sencha.com/learn/Ext_FAQ_TabPanel

风吹短裙飘 2024-10-15 15:50:04
There is no event for tab click in TabPanel, however you can bind into click event on each tab. You can add custom event. 
Following example help to you. 


{
  xtype : 'tabpanel',
  items : [{
    xtype : 'panel', 
    title:  'ABC'
   },{
      xtype : 'panel',
      title : 'XYZ'
}],
  listeners: {
    render: function() {
     this.items.each(function(panel){
         // Added tabclick event for tabpanel                                                                        
         panel.tab.on('click', function(){
       panel.addEvents('tabclick');  // addded event to panel 
       panel.fireEvent('tabclick', panel);
      });
       });
      }
    }
        }
There is no event for tab click in TabPanel, however you can bind into click event on each tab. You can add custom event. 
Following example help to you. 


{
  xtype : 'tabpanel',
  items : [{
    xtype : 'panel', 
    title:  'ABC'
   },{
      xtype : 'panel',
      title : 'XYZ'
}],
  listeners: {
    render: function() {
     this.items.each(function(panel){
         // Added tabclick event for tabpanel                                                                        
         panel.tab.on('click', function(){
       panel.addEvents('tabclick');  // addded event to panel 
       panel.fireEvent('tabclick', panel);
      });
       });
      }
    }
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文