选项卡项目的侦听器单击Sencha [英] Listener to Tab Item Click in Sencha

查看:159
本文介绍了选项卡项目的侦听器单击Sencha的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我正在使用一个包含5个项目的标签面板.每个项目包含大约6个面板(在卡片布局中添加).当我位于选项卡项中的最后一个面板时,我需要通过单击底部的选项卡面板(与iOS中的常规选项卡视图控制器类似)来返回到初始面板.我遇到了

In my application, I'm using a tab panel with 5 items in it. Each item holds around 6 panels added in card layout. When I'm at the last panel inside a tab item, I need to get back to the initial panel by clicking on the bottom tab panel (somewhat similar to a normal tab view controller in iOS). I have came across some solutions I found here, but it seems to work only when I switch between the tabs. In fact I want to listen to the click event on the same tab icon. How can I do this?

推荐答案

我已经解决了您的问题.我认为这正是您想要的.希望这可以帮助.如果不是这样,请发表评论.

I have worked on your problem. I think this is exactly what you want. Hope this helps. If not so, please leave a comment.

1). 查看(MyTabPanel1.js)

    Ext.define('MyApp.view.MyTabPanel1', {
    extend: 'Ext.tab.Panel',
    config: {

            scrollable: 'vertical',
             items:
            [
                {
                   xtype: 'panel',
                   id:'cardpanel1',
                   title: 'Tab1',              
                   layout: 'card',
                        items: [
                            {  
                                html: "First Item",
                                items:
                                [
                                {
                                    xtype: 'button',
                                    text: 'Forward',
                                    handler: function() {
                                    Ext.getCmp('cardpanel1').setActiveItem(1);
                                    console.log('Going to Second Item');
                                    }
                                }
                                ]
                            },
                            {
                                html: "Second Item",
                                items:
                                [
                                {
                                    xtype: 'button',
                                    ui: 'confirm',
                                    text: 'Go back',
                                    handler: function() {
                                    Ext.getCmp('cardpanel1').setActiveItem(0);
                                    console.log('Going to First Item');
                                    }
                                }
                                ]
                            }

                        ]               

                },

                {
                    xtype: 'panel',
                    title: 'Tab2',
                    scrollable: true,
                    items: [
                        {
                            xtype: 'button',
                            margin: 10,
                            ui: 'action',
                            text: 'Tab2'
                        }

                    ]
                },
                {
                    xtype: 'panel',
                    title: 'Tab3',
                    scrollable: true,
                    items: [
                        {
                            xtype: 'button',
                            margin: 10,
                            ui: 'action',
                            text: 'Tab3'
                        }
                    ]
                }

            ]
        }

    });

2). 控制器(MainController.js)

    Ext.define('MyApp.controller.MainController', {
        extend: 'Ext.app.Controller',
        config: {
            control: {

                "tabpanel #ext-tab-1":{  //ext-tab-1 is the id for the 1st tab generated by Sencha
                   tap: 'ontap'
                }            
            }
        },

        ontap: function (){
        console.log('inside controller');
        Ext.getCmp('cardpanel1').setActiveItem(0);
        }

    });

这篇关于选项卡项目的侦听器单击Sencha的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆