2012-12-19 46 views

回答

21

你可以用一招归档此:

Ext.create('Ext.panel.Panel', { 
    title: 'Toolbar Fill Example', 
    width: 300, 
    height: 200, 
    tbar : [ 
     'Item 1', 
     { xtype: 'tbfill' }, 
     'Item 4', 
     { xtype: 'tbfill' }, 
     'Item 2' 
    ], 
    renderTo: Ext.getBody() 
}); 

JSFiddle

需要注意的是:

[ 
    'Item 1', 
    '->', 
    'Item 4', 
    '->', 
    'Item 2' 
] 

工作都是一样的。

它是如何工作的

->,或者它的xtype tbfill无非是空的组件更具有flex: 1配置。

+0

非常感谢!这正是我所期待的。 – seba

+1

这只会保持中间项目居中,假设它们都具有相同的宽度。您可以制作最后一个项目“Item 10102598”,您将看到中间项目不再居中。 – Slims

1

dockedItems:[{ 的xtype: '工具栏', buttonAlign: '中心', 坞: '顶部', 项目:[{ 文本: '停靠顶端' }] }]

3
Ext.create('Ext.panel.Panel', { 
    title: 'Toolbar Fill Example', 
    width: 300, 
    height: 200, 
    tbarCfg:{ 
      buttonAlign:'center' //for center align 
     // buttonAlign:'left' //for left align 
     // buttonAlign:'right' //for right align 
    }, 
    tbar : [ 
     'Item 1', 
     { xtype: 'tbfill' }, 
     'Item 4', 
     { xtype: 'tbfill' }, 
     'Item 2' 
    ], 
    renderTo: Ext.getBody() 
}); 
+2

不适合我。 –

1
For Right:  
bbar: ['->',{ 
        xtype: 'button', 
        text: 'xyz', 

       }] 

For Left:  
bbar: ['<-',{ 
        xtype: 'button', 
        text: 'xyz', 

       }] 
相关问题