0

我有以下带有几个按钮的容器:

{
                    xtype : 'container',
                    width : 320,
                    layout : 'hbox',
                    cls : 'readable-form no-border',
                    labelSeparator : '',
                    ref : '../sendBackForm',
                    layoutConfig: {
                        padding:'5',
                        pack:'center',
                        align:'middle'
                    },
                    style : {
                        margin : 'auto'
                    },
                    items : [ {
                        xtype : 'button',
                        itemId : 'yes',
                        iconCls : 'save-button-icon',
                        text : 'Yes',
                        ref : '../../yes'
                    }, {
                        xtype : 'spacer',
                        width : 10
                    }, {
                        xtype : 'button',
                        itemId : 'checker',
                        iconCls : 'save-button-icon',
                        text : 'Back to checker',
                        ref : '../../checker'
                    }, {
                        xtype : 'spacer',
                        width : 10
                    }, {
                        xtype : 'button',
                        itemId : 'prebooker',
                        iconCls : 'save-button-icon',
                        text : 'Back to prebooker',
                        ref : '../../prebooker'
                    }, {
                        xtype : 'spacer',
                        width : 10
                    }, {
                        xtype : 'button',
                        itemId : 'cancel',
                        text : 'Cancel',
                        ref : '../../cancel'
                    }, {
                        xtype : 'spacer',
                        width : 90
                    }, {
                        xtype : 'button',
                        itemId : 'ok',
                        hidden : true,
                        text : 'Ok',
                        ref : '../../ok'
                    } ]

                }

问题是当我隐藏所有按钮并只想显示确定按钮时,它出现在左窗口角附近,我如何将它放在窗口中间?

4

3 回答 3

1

您是否尝试过在容器上添加以下代码?:autoEl: {tag: 'center'}

于 2013-10-28T14:18:53.737 回答
1

您可以尝试在“确定”按钮之前和之后放置垫片,

...
items: [
...
{xtype: 'tbspacer', flex: 1},
{
    xtype : 'button',
    itemId : 'btnok',
    hidden : true,
    text : 'Ok',
    ref : '../../ok'
},
{xtype: 'tbspacer', flex: 1}
...

和“确定”和“取消”按钮处理程序

....
bindHandlers: function(){
    var me = this;
    me.getComponent('btnok').on('click', function(){
        me.toggleButtons(true);
    });

    me.getComponent('btncancel').on('click', function(){
        me.toggleButtons(false);
    });      
},
toggleButtons: function(visible){
    this.getComp('btnyes').setVisible(visible);
    this.getComp('checker').setVisible(visible);
    this.getComp('prebooker').setVisible(visible);
    this.getComp('btncancel').setVisible(visible);
    this.getComp('btnok').setVisible(!visible);
}
...

或者在“OK”按钮前后手动添加垫片

于 2013-10-29T06:50:28.680 回答
0

看起来layoutConfig 将不再起作用在布局配置本身中设置“pack”和“align”,在这里摆弄(单击“Yes”按钮隐藏除“Ok”之外的所有内容)

于 2013-10-31T05:02:28.647 回答