简体   繁体   English

具有复合字段的ExtJS自动宽度布局

[英]ExtJS auto width layout with composite field

Using ExtJS 4.2.1 I'm trying to add a 'composite' control to my Form Panel that consists of a textfield and a button next to it (which will invoke a lookup dialog). 使用ExtJS 4.2.1我试图在我的Form面板中添加一个“复合”控件,它由一个textfield和一个旁边的button组成(它将调用一个查找对话框)。 I've implemented this as follows: 我已经实现了如下:

Ext.onReady(function () {

    Ext.create('Ext.form.Panel', {
        renderTo: Ext.getBody(),
        defaults:{
            anchor:'100%',
            border: 0
        },
        items: [{
            xtype: 'textfield',
            fieldLabel: 'foo'
        }, {
            xtype: 'panel',
            layout:'hbox',
            items: [{
                xtype: 'textfield',
                fieldLabel: 'bar' 
            }, {
                text: '...',
                xtype: 'button'
            }]
        }]

    });


});

The problem I have is in terms of Layout. 我遇到的问题是布局。 I want the 'bar' textfield to shrink/grow to fill the available width of the form, but it's currently maxing out at a fixed width, even when the 'foo' textfield extends correctly across the width of the form 我希望'bar'文本字段缩小/增长以填充表单的可用宽度,但它当前以固定宽度最大化,即使'foo'文本字段在表单的宽度上正确延伸

表格布局

Please advise the correct layout settings? 请告知正确的布局设置? jsFiddle 的jsfiddle

Just add flex:1 to your bar text box config. 只需将flex:1添加到条形文本框配置中即可。 As its being managed by a hbox layout this is required to tell the item to fill up as much space (width) as possible 由于它是由hbox布局管理的,因此需要告诉项目尽可能多地填充空间(宽度)

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

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