Search code examples
javascriptextjsnavigationpanel

Is It right way to create side collapsible panel navigation in extjs


Ext.application({
    name: 'Fiddle',
    launch: function() {
            var mainView = new Ext.panel.Panel({
            xtype: 'panel',
            //title: 'Container',
            layout: 'border',
            itemId: 'bigContainer',
            height: '100vh',
            items: [{
                xtype: 'panel',
                //title: 'Left Panel',
                itemId: 'menuLeftPanel',
                region: 'west',
                scrollable: true,
                //width: 300,
                //height: 900,
                dockedItems:
                [{
                    xtype: 'tabpanel',
                    collapseMode: 'header',
                    //animCollapse: 200,
                    dock: 'left',
                    id: 'moduleTas',
                    itemId: 'moduleTabs',
                    width: 400,
                    collapsible: true,
                    headerPosition: 'left',
                    hideCollapseTool: true,
                    //activeTab: 0,
                    tabBarHeaderPosition: 0,
                    tabRotation: 0,
                    items: [{
                        xtype: 'panel',
                        scrollable: 'y',
                        tabConfig: {
                            xtype: 'tab',
                            iconCls: 'x-fa fa-home',
                            tooltip: "Home",
                            listeners:
                            {
                                click: function(btn, e, eOpts)
                                {
                                    var tab = Ext.getCmp('moduleTas');
                                    tab.toggleCollapse();
                                }
                            }
                        },
                    },
                    ]
                },
                ]
            }],
            renderTo: Ext.getBody()
        });
    }
});

Solution

  • Sencha provides an "Admin Dashboard" example application when you download the framework, that implements collapsible side navigation. All the source code for the below layout (and every component found in the kitchen sink) can be found in the framework download.

    Admin Dashboard

    Admin Dashboard Source Code

    This isn't something you should be recreating yourself (defeats the point of using a framework like Extjs)