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

    }); 
    myWin.show(); 

這是我的代碼。我想按鈕居中,我知道有辦法做到這一點,但他們有點長,棘手,是否有一個簡單的解決方案,如align : center或類似的東西,應該按鈕或文本字段居中?ExtJS中的中心對齊按鈕

回答

2

enter image description here

您可以試試這個。這是一種方式(我添加了我的窗口的圖片)

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); 
    } 
}); 
2

插入buttonAlign: 'center',它應該居中 - 默認爲right,我想。見this example