extJs工具栏只采用nessassary大小

时间:2011-03-14 14:22:36

标签: javascript extjs

我希望工具栏只需要\ autosize ..我该怎么做?

MyViewportUi = Ext.extend(Ext.Viewport, {
layout: 'fit',
initComponent: function() {
    this.items = [
        {
            xtype: 'panel',
            title: 'My Panel',
            layout: 'vbox',
            tbar: {
                xtype: 'toolbar',
                items: [
                    {
                        xtype: 'button',
                        text: 'MyButton 1'
                    },
                    {
                        xtype: 'button',
                        text: 'MyButton 2'
                    }
                ]
            }
        }
    ];
    MyViewportUi.superclass.initComponent.call(this);
}
});

1 个答案:

答案 0 :(得分:0)

因为工具栏只是一个条形图,它将展开以填充所有可用空间。放置在工具栏内的按钮将占用所需的空间,但工具栏仍将展开以填充可能的最大宽度。

Ext.Toolbar有一个名为autoWidth的属性,但这只会导致工具栏使用css width: auto属性。这不是完美的,但它可能是你最好的选择。