views:

1694

answers:

3

In ExtJS, I'm having a little trouble placing two fieldsets side-by-side in a panel with a hbox layout. The hbox layout seems to be unaware of the fieldset's height, and cuts it off, even if I explicitly set the panel's height to something large.

Here's what it looks like:

The blue border is the hbox panel, and there's 2 fieldsets inside, 'Client Info' and 'Owner Info'. The code is like so (simplified and runnable in Firebug):

var clientInfo = {
    xtype: 'fieldset',
    defaultType: 'textfield',
    title: 'Client Info',
    items:
    [
        { fieldLabel: 'First Name' },
        { fieldLabel: 'Last Name' },
        { fieldLabel: 'Cell Phone #' },
        { fieldLabel: 'Work Phone #' }
    ]
};

var ownerInfo = {
    xtype: 'fieldset',
    defaultType: 'textfield',
    title: 'Owner Info',
    items:
    [
        { fieldLabel: 'First Name' },
        { fieldLabel: 'Last Name' },
        { fieldLabel: 'Cell Phone #' },
        { fieldLabel: 'Work Phone #' }
    ]
};

new Ext.Panel({
    layout: 'hbox',
    frame: true,
    height: 400,
    width: 800,
    defaults: { flex: 1 },
    items: [ clientInfo, ownerInfo ]
}).render(document.body);

P.S. If you remove defaults: { flex: 1 }, the fieldsets render correctly, but doesn't automatically resize to fit the container, which is something I need.

Does anybody know how to fix this rendering issue? Thanks.

A: 

Try autoHeight: true in your fieldsets.

Another alternative might be a column layout where each column is given 50% of the available width.

Upper Stage
`autoHeight: true` does not work. I've resorted to using a `column` layout for now, but it seems odd that this doesn't work with a `hbox` layout.
Daniel T.
I agree. From the image you attached, it appears as though it is a problem with height. I am curious, did you try hardcoding a height with hbox?
Upper Stage
I posted it as a bug report and got a response here: http://www.extjs.com/forum/showthread.php?t=93440. Basically, it's a known bug that's fixed in ExtJS 3.2 beta.
Daniel T.
Cool - thanks for the post.
Upper Stage
A: 

Have you tried layoutConfig:{align:'stretch'} on the panel, together with autoHeight: true in your fieldsets ?

Works for me on ExtJS 3.1.0

ob1
A: 

I had a lot of issues with vbox and hbox until I started explicitly setting the three main layoutConfig options:

layoutConfig: {
   flex: 1,
   align: 'stretch',
   pack: 'start'
}

From reading their API, it sounded like specifying a 'flex' value in the layoutConfig was akin to a default, but since setting it and my layouts work correctly I've come to believe that it is a required field against which children's flex values are, at some point, compared to/ with.

That's just speculation on my part though - all I really cared about was that using that fixed my layout heh.

mrusinak