繁体   English   中英

Ext JS 4和fieldcontainer位置的对齐问题

[英]Alignment Issue With Ext JS 4 and fieldcontainer position

我有一个窗口,在该窗口内有一个面板(在整个窗口中占满整个空间),在面板的内侧有两个水平方向的fieldcontainers ,分别在左侧和右侧。

----------------------------
|            |             |
|            |             |
|  left FC   |  right FC   |
|            |             |
|            |             |
|            |             |
----------------------------

两者都可以在运行时中隐藏,但是当我设置FC_left.Visible(false)右边的fieldcontainer边框不在窗口的左侧,但是在左边的窗口边框和左边的(该右边的fieldcontainer )容器边框之间有很大的余量。 像这样:

----------------------------
|     |                    |
|     |                    |
|     |      right FC      |
|     |                    |
|     |                    |
|     |                    |
----------------------------

当左侧容器不可见时,我想在左侧位置看到右侧容器。 怎么做?

您需要向fieldcontainer提供flex:1width:'50%'

在此FIDDLE中 ,我使用panelfieldcontainer创建了一个演示。 我希望这会帮助/指导您达到要求。

代码片段

Ext.application({
    name: 'Fiddle',

    launch: function () {

        /*
         * this function will fire when hide/show button clicked
         * @param {Ext.button.Button}
         */
        function onHideShow(btn) {

            var fCnt = btn.up('panel').down(`#${btn.label}`);

            if (fCnt.isHidden()) {
                fCnt.setVisible(true);
                btn.setText(`Hide ${btn.label}`);
            } else {
                fCnt.setVisible(false);
                btn.setText(`Show ${btn.label}`);
            }
        }

        //Create panel with field container
        Ext.create('Ext.panel.Panel', {

            title: 'Basic example',

            //height:400,

            layout: 'hbox',

            bodyPadding: 10,

            defaults: {
                xtype: 'fieldcontainer',

                flex: 1,

                //width:'50%',

                style: 'border: 2px solid #ccc;',

                labelAlign: 'top',
                // The body area will contain three text fields, arranged
                // horizontally, separated by draggable splitters.
                layout: 'vbox',
                defaults: {
                    width: '100%',
                    margin: '5 10'
                },
                items: [{
                    xtype: 'textfield',
                    flex: 1
                }, {
                    xtype: 'splitter'
                }, {
                    xtype: 'textfield',
                    flex: 1
                }, {
                    xtype: 'splitter'
                }, {
                    xtype: 'textfield',
                    flex: 1
                }]
            },

            items: [{
                itemId: 'Left',
                fieldLabel: 'Left field container',
                margin: '0 5'
            }, {
                itemId: 'Right',
                fieldLabel: 'Right field container'
            }],

            tbar: ['->', {
                text: 'Hide Left',
                label: 'Left',
                handler: onHideShow
            }, {
                text: 'Hide Right',
                label: 'Right',
                handler: onHideShow
            }],

            renderTo: Ext.getBody()
        });
    }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM