Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center-align a button in ExtJS

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?

like image 887
Raza Ahmed Avatar asked Mar 11 '26 07:03

Raza Ahmed


2 Answers

enter image description here

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);
    }
});
like image 154
Nail Shakirov Avatar answered Mar 13 '26 19:03

Nail Shakirov


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