admin管理员组

文章数量:1308191

var myWin = new Ext.Window({
        height : 100,
        width : 200,
        maximizable : true,
        items : [ {
            xtype : 'button',
            text : 'myButton'
         // align : center
        } ]

    });
    myWin.show();

This is my code. I want to align the button to center, i know there are ways to do that but they are a bit long and tricky, is there a simple solution like align : center or something like that, that should align button or text fields to center?

var myWin = new Ext.Window({
        height : 100,
        width : 200,
        maximizable : true,
        items : [ {
            xtype : 'button',
            text : 'myButton'
         // align : center
        } ]

    });
    myWin.show();

This is my code. I want to align the button to center, i know there are ways to do that but they are a bit long and tricky, is there a simple solution like align : center or something like that, that should align button or text fields to center?

Share Improve this question edited Nov 4, 2013 at 14:38 mustafa.0x 1,5062 gold badges18 silver badges30 bronze badges asked May 27, 2013 at 8:19 Raza AhmedRaza Ahmed 2,7512 gold badges37 silver badges47 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

You can try this. It's one way(I add picture of my window)

 Ext.define('MyApp.view.MyWindow', {
    extend: 'Ext.window.Window',

    height: 137,
    width: 233,
    layout: {
        align: 'middle',
        pack: 'center',
        type: 'hbox'
    },
    title: 'My Window',

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'button',
                    text: 'MyButton'
                }
            ]
        });
        me.callParent(arguments);
    }
});

Insert buttonAlign: 'center', and it should center - the default is right, I think. See this example.

本文标签: javascriptCenteralign a button in ExtJSStack Overflow