sencha extjs4.1 ext.tab.panel activetab

时间:2015-07-17 14:44:50

标签: javascript extjs extjs4.1 sencha-architect

如何在tab.panel中使用setactivetab作为网格? 我需要我的onload按钮/网格留在它激活的选项卡面板中。 当我从第二个选项卡中单击按钮时,我想要设置第二个选项卡。而是返回第一个选项卡。下面是我的骨头代码,因为我删除了尝试使用setactivetab:

<script type="text/javascript">
//begin menu bar
Ext.define('MainNavBar.view.ui.MainNavPanel', {
    extend: 'Ext.tab.Panel',
    height: 170,
    width: 1000,
    activeTab: 0,
    initComponent: function() {    
        var me = this;
        me.items = [
            {
                xtype: 'panel',
                height: 145,
                width: 684,
                title: 'Bus Data',
                dockedItems: [
                    {
                        xtype: 'toolbar',
                        height: 145,
                        width: 938,
                        dock: 'top',
                        items: [

                            {
                                xtype: 'buttongroup',
                                height: 140,
                                title: 'Bid',
                                columns: 2,
                                layout: {
                                    columns: 2,
                                    type: 'table'
                                },
                                items: [
                                    {
                                        xtype: 'button',
                                        text: 'Bid Doc',
                                        handler: function(){window.location = '/biddoc/';}                                        
                                    },
                                ]
                            },
                        ]
                    }
                ]
            },
            {
                xtype: 'panel',
                height: 115,
                title: 'Reporting',
                dockedItems: [
                    {
                        xtype: 'toolbar',
                        height: 140,
                        dock: 'top',
                        items: [
                            {
                                xtype: 'buttongroup',
                                height: 140,
                                title: 'Sales Data',
                                columns: 2,
                                layout: {
                                    columns: 2,
                                    type: 'table'
                                },
                                items: [
                                    {
                                        xtype: 'button',
                                        text: 'Batch',
                                        handler: function(){window.location = '/salesdatabatch/';}  
                                    }
                                ]
                            }
                        ]
                    }
                ]
            },

        ];
        me.callParent(arguments);
    }
});       
Ext.define('MainNavBar.view.MainNavPanel', {
    extend: 'MainNavBar.view.ui.MainNavPanel',

    initComponent: function() {
        var me = this;
        me.callParent(arguments);
    }
});
Ext.Loader.setConfig({
    enabled: true
});
Ext.application({
    name: 'MainNavBar',
    launch: function() {
        Ext.QuickTips.init();

        var cmp1 = Ext.create('MainNavBar.view.MainNavPanel', {
            renderTo: menu
        });
        cmp1.show();
    }
});
//end menu bar

        </script>

1 个答案:

答案 0 :(得分:0)

让我们编译我们在这里讨论的所有内容并做出正确答案。

@Lorenz Meyer在那里有好处。您遇到了架构问题,可以通过Ext.Ajax.request({/** code here **/});解决此问题。所以没有重定向。
如果您需要很好的示例,请参阅:Extjs - Servlets

但你没有要求建筑问题所以这是我的答案。

所以经过一番思考后我才对你的代码做了一些修改。请看一下,如果您喜欢的东西只是标记为已回答:

Ext.define('MainNavBar.view.ui.MainNavPanel', {
    extend: 'Ext.tab.Panel',
    height: 170,
    width: 1000,
    activeTab: 0,
    initComponent: function() {    
        var me = this;
        me.items = [
            {
                xtype: 'panel',
                height: 145,
                width: 684,
                title: 'Bus Data',
                dockedItems: [
                    {
                        xtype: 'toolbar',
                        height: 145,
                        width: 938,
                        dock: 'top',
                        items: [

                            {
                                xtype: 'buttongroup',
                                height: 140,
                                title: 'Bid',
                                columns: 2,
                                layout: {
                                    columns: 2,
                                    type: 'table'
                                },
                                items: [
                                    {
                                        xtype: 'button',
                                        text: 'Bid Doc',
                                        handler: function(){window.location = '/biddoc/';}                                        
                                    },
                                ]
                            },
                        ]
                    }
                ]
            },
            {
                xtype: 'panel',
                height: 115,
                title: 'Reporting',
                dockedItems: [
                    {
                        xtype: 'toolbar',
                        height: 140,
                        dock: 'top',
                        items: [
                            {
                                xtype: 'buttongroup',
                                height: 140,
                                title: 'Sales Data',
                                columns: 2,
                                layout: {
                                    columns: 2,
                                    type: 'table'
                                },
                                items: [
                                    {
                                        xtype: 'button',
                                        text: 'Batch',
                                        handler: function(){window.location = '/salesdatabatch/';}  
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ],
        listeners: {
            afterrender: function(component, eOpts) {
                var urlInfo = document.location.href;
                if(urlInfo.contains('salesdatabatch')){
                    component.setActiveTab(1);
                }
                if(urlInfo.contains('biddoc')){
                    component.setActiveTab(0);
                }
            }
        },
        me.callParent(arguments);
    }
});