EXTJS Dynamically put a component into a container with other components

后端 未结 1 1319
孤街浪徒
孤街浪徒 2021-01-26 05:15

I\'d like to achieve this behavior:

If a field (combo, text, date ...) in a form panel has a custom property set true

 {
    xtype: \'textfield\',
    fi         


        
相关标签:
1条回答
  • 2021-01-26 06:08

    It is.

    Ext.require('*');
    
    Ext.onReady(function() {
    
        var form = new Ext.form.Panel({
            renderTo: document.body,
            width: 400,
            height: 100,
            items: {
                xtype: 'textfield',
                fieldLabel: 'Foo'
            }
        });
    
        setTimeout(function() {
            var field = form.down('textfield');
    
            // We have a reference to the field, let's go!
            var owner = field.ownerCt;
    
            owner.remove(field, false);
            owner.add({
                xtype: 'container',
                layout: 'hbox',
                items: [field, {
                    xtype: 'button',
                    text: 'Foo'
                }]
            });
        }, 1000);
    
    });
    

    Where container is a reference to the container with the hbox layout.

    0 讨论(0)
提交回复
热议问题