The 'fit' layout is designed to accommodate one panel only. Instead, use the 'card' layout to switch between two or more panels that should share the same space:
{ region: 'center', layout: 'card', // 0 here means the zeroth element of the items array. activeItem: 0, items: [ gridCourses, gridExams ] }
Then your button handlers become:
{ text: 'Courses', iconCls: 'show-courses', handler: function() { gridCourses.getStore().reload(); gridCourses.ownerCt.getLayout().setActiveItem(gridCourses); } }, { text: 'Exams', iconCls: 'show-exams', handler: function() { gridExams.getStore().reload(); gridExams.ownerCt.getLayout().setActiveItem(gridExams); } }
In addition, if the toolbar variable in your example contains a real instance of Ext.Toolbar, your layout as a whole can be improved with another view view definition:
new Ext.Viewport({ layout: 'fit', items: { xtype: 'panel', layout: 'card', activeItem: 0, tbar: [ { text: 'Courses', iconCls: 'show-courses', handler: function() { gridCourses.getStore().reload(); gridCourses.ownerCt.getLayout().setActiveItem(gridCourses); } }, { text: 'Exams', iconCls: 'show-exams', handler: function() { gridExams.getStore().reload(); gridExams.ownerCt.getLayout().setActiveItem(gridExams); } } ], items: [ gridCourses, gridExams ] } });
However, if you still need a border layout in your viewport for other reasons, then the map panel, toolbar and everything can be parked in the center area, as shown at the top of the answer.