Results 1 to 2 of 2

Thread: Can't get simple 4box layout working with flex

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    UK
    Posts
    28
    Answers
    1
    Vote Rating
    0
      0  

    Default Answered: Can't get simple 4box layout working with flex

    I am trying to do a simple 4 box layout (i.e. have a screen divided into 4 panels which will each have different content.
    If I use fixed height/width for each hbox/vbox then it works fine however if I try to use flex then I just get everything squashed into a few pixels in the middle of the screen. I have tried using %ge height/width but these also do not seem to work. I need to use flex so that it will work on differnet device formats.

    This is the code as is but I have tried every combination that I can think of
    Code:
    STmenu7=new Ext.Panel(
        {cardpanel:"MainCardPanel",id:"MenuPnl",layout:"fit",transition:"pop",items:[
        {align:"stretch",flex:1,id:"mp1",layout:"vbox",xtype:"panel",items:[
            {align:"stretch",flex:1,id:"mp2",layout:"hbox",xtype:"panel",items:[
                {flex:1,id:"mpb1",xtype:"panel"}
               ,{flex:1,id:"mpb2",xtype:"panel"}
                ]
            }
            ,{align:"stretch",flex:1,id:"mp3",layout:"hbox",xtype:"panel",items:[
                {flex:1,id:"mpb3",xtype:"panel"}
                ,{flex:1,id:"mpb4",xtype:"panel"}
                ]
            }
        ]}
        ]}
    );
    I am sure it must be something obvious as this seems such a basic requirement but I just can't seem to get it to work and would appreciate any help.

  2. Can't read your code as it's all jumbled up but here is an example that works for me:

    Code:
    new Ext.Container({
        fullscreen : true,
        layout     : {
            type  : 'hbox',
            align : 'stretch'
        },
        items      : [
            {
                xtype  : 'container',
                flex   : 1,
                layout : {
                    type  : 'vbox',
                    align : 'stretch'
                },
                items  : [
                    {
                        xtype : 'button',
                        flex  : 1,
                        text  : 'Top-Left'
                    },
                    {
                        xtype : 'button',
                        flex  : 1,
                        text  : 'Bottom-Left'
                    }
                ]
            },
            {
                xtype  : 'container',
                flex   : 1,
                layout : {
                    type  : 'vbox',
                    align : 'stretch'
                },
                items  : [
                    {
                        xtype : 'button',
                        flex  : 1,
                        text  : 'Top-Right'
                    },
                    {
                        xtype : 'button',
                        flex  : 1,
                        text  : 'Bottom-Right'
                    }
                ]
            }
        ]
    });

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    Can't read your code as it's all jumbled up but here is an example that works for me:

    Code:
    new Ext.Container({
        fullscreen : true,
        layout     : {
            type  : 'hbox',
            align : 'stretch'
        },
        items      : [
            {
                xtype  : 'container',
                flex   : 1,
                layout : {
                    type  : 'vbox',
                    align : 'stretch'
                },
                items  : [
                    {
                        xtype : 'button',
                        flex  : 1,
                        text  : 'Top-Left'
                    },
                    {
                        xtype : 'button',
                        flex  : 1,
                        text  : 'Bottom-Left'
                    }
                ]
            },
            {
                xtype  : 'container',
                flex   : 1,
                layout : {
                    type  : 'vbox',
                    align : 'stretch'
                },
                items  : [
                    {
                        xtype : 'button',
                        flex  : 1,
                        text  : 'Top-Right'
                    },
                    {
                        xtype : 'button',
                        flex  : 1,
                        text  : 'Bottom-Right'
                    }
                ]
            }
        ]
    });
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •