View Full Version : [CLOSED]Fit layout with multiple items

James Goddard
8 Mar 2011, 8:06 AM
I'm not sure if this is considered a bug or not, but in Ext 3 I could place multiple items in a container with a fit layout. As long as only 1 item was visible, it would show. I used to use this to swap views in and out based on external events. Now with Ext 4, only the first item will show period. See the following example:

Ext.onReady(function () {
var panel = Ext.create('Ext.Panel', {
renderTo: Ext.getBody(),
layout: 'fit',
title:'Item 1',
hidden: true
title:'Item 2'

In ext 3 this would show a panel titled 'Item 2', but with ext 4 it shows nothing.

8 Mar 2011, 8:24 AM
for the 2 items in your example, you should use hbox / vbox, fit is meant for single ones.

best regards

8 Mar 2011, 8:35 AM
HBoxLayout and VBoxLayout is good if you want multiple showing at once.

Sounds like he wants one shown at a time and be 100% it's parents' width/height (aka fit). So I would suggest using CardLayout.

8 Mar 2011, 8:59 AM
oh, i missed that one item is hidden.
then he might really have tried to simulate a card-layout :)

James Goddard
8 Mar 2011, 9:10 AM
I'm aware that other layouts can do this which is why I questioned weather or not it is actually considered a bug. It is, however, different functionality from Ext 3 which showed the first visible item in a fit layout, whereas Ext 4 will only show the first item period.

8 Mar 2011, 9:13 AM
Most definitely not a bug.

Fit layout handles one item. Only ever one item.