how to align grid Panel in center
Asked Answered
N

5

6

I am placing Ext JS Grid Panel in a iFrame. Do anybody know how can I place it in the center of the iFrame.

Currently It look like this - Currently It look like this

I want it to be like this - I want it to be like this

Nectareous answered 4/7, 2011 at 10:52 Comment(0)
W
5

The contents of your IFrame can use a border layout as above or no layout, like this:

var viewPort = new Ext.Viewport({
    renderTo:'body',
    width: 400,
    height: 400,
    items:[new Ext.Panel({
        title: 'hi',
        width: 200,
        height: 200,
        style: 'margin:0 auto;margin-top:100px;'
    })]

});

Wortman answered 4/7, 2011 at 12:10 Comment(1)
Thanks Skym. one more question: #6594567Nectareous
C
3

In the examples site there is an example that does this you may want to look at.

layout:'ux.center',
items: {
    title: 'Centered Panel',
    widthRatio: 0.75,
    html: 'Some content'
}
Cenogenesis answered 4/7, 2011 at 12:15 Comment(1)
apparently this has side-effects sencha.com/forum/…Spiegelman
R
1

Another way, not as elegant, is a cludge of VBox and HBox layouts but is pure ExtJS and doesn't rely on UX:

Ext.create('Ext.container.Viewport',{
    style: 'background-color: white;',

    layout: {
        type: 'vbox',
        align : 'stretch',
        pack  : 'start',
    },
    items: [{
        flex: 1,
        border: false
    },{
        height: 200,
        border: false,
        layout: {
            type: 'hbox',
            pack: 'start',
            align: 'stretch'
        },
        items: [{
            flex: 1,
            border: false
        },{
            html:'Centered Panel',
            width: 400
        },{
            flex: 1,
            border: false
        }]
    },{
        flex: 1,
        border: false
    }]

    //items: [login_panel],

});
Ricoriki answered 3/9, 2012 at 12:26 Comment(0)
M
1

simply use:

this.center()

where as "this" is the object you want to put in the center (let's say grid).

Muck answered 31/12, 2013 at 14:0 Comment(0)
B
0

Something like

grid:
  region: center;

panel:
  layout: border;
  css: "padding: 40px"
Blind answered 4/7, 2011 at 11:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.