在ExtJS中,在组合框旁边添加按钮

3

我有一个面板,其中有2个下拉框。我需要在其中一个下拉框旁边添加一个按钮。两个下拉框和按钮应该在同一行上。以下是我的面板:

filterPanel = new Ext.Panel({
        renderTo: document.body,
          bodyStyle: 'padding-top: 6px;',
    title: 'Filters',
        collapsible: true,
        collapsed: true,
        shadow: 'sides',
        width: 400,
        frame: true,
        floating: true,
        layout: 'form',
        labelWidth: 150,
        buttonAlign: 'center',
        items: [
            {
                xtype: 'combo',
                id: 'xFilter',
                width: 200,
                listWidth: 200,
                fieldLabel: 'Filter',
                store: filterStore,
                displayField:'filterDisp',
                valueField:'filterVal',
                typeAhead: true,
                editable: true,
                mode: 'local',
                forceSelection: true,
                triggerAction: 'all',
                selectOnFocus:false
            },{
                xtype: 'combo',
                id: 'xStatus',
                width: 200,
                listWidth: 200,
                fieldLabel: 'Status',
                store: statusStore,
                displayField:'statusDisp',
                valueField:'statusVal',
                typeAhead: true,
                editable: false,
                mode: 'local',
                forceSelection: true,
                triggerAction: 'all',
                selectOnFocus:false
            }
        ]
    });

我需要将按钮放在第一个组合框旁边,以便第一个组合框和按钮在同一行显示。 请问有人能帮我完成这个任务吗?
提前感谢您的帮助。
2个回答

3
在ExtJS 4中,由于 'compositefield' 不再可用,您可以改用 'fieldcontainer'。
var config = {
    xtype:'fieldcontainer',
    layout:'hbox',
    fieldLabel: 'Combobox',
    items:[{
        xtype: 'combo',
        flex:1
        //rest of combo config,
    },{
        xtype:'button',
        text: 'Add New',
        handler: function(){
            //add new record
        }
    }]
};

0

尝试使用复合字段

{
    xtype: 'compositefield',
    labelWidth: 120
    items: [
        {
            xtype     : 'textfield',
            fieldLabel: 'Title',
            width     : 20
        },
        {
            xtype     : 'textfield',
            fieldLabel: 'First',
            flex      : 1
        },
        {
            xtype     : 'textfield',
            fieldLabel: 'Last',
            flex      : 1
        }
    ]
}

或者使用hboxcolumn布局。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接