开发者

how to align grid Panel in center

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 -

how to align grid Panel in center

I want it to be like this -

how to align grid Panel in center


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;'
    })]

});


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'
}


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],

});


simply use:

this.center()

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


Something like

grid:
  region: center;

panel:
  layout: border;
  css: "padding: 40px"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜