2

在这个简短函数的最底部,您可以看到我正在尝试将所有内容都xtype: button包含在webClip. 出于某种原因,它省略了 57x57 按钮,仅显示从titlebar. 我不知道为什么。Thisxtype: fieldcomponent配置对我来说相当混乱。谢谢!

function addWebClip(type) {

    var webClip = Ext.create('Ext.form.FieldSet', {

        cls: 'webclip-title',

        items: [{
            xtype: 'titlebar',
            title: type + ' webclip',


            items: [{
                text: 'remove',
                ui: 'decline',
                align: 'right',


                handler: function () {
                    console.log(this.hasParent()); // TRUE
                    Ext.getCmp('main-panel').remove(this.up('fieldset'));
                }
            }]
        }, {
            xtype: 'field',
            label: 'Icon',
            cls: 'icon-input',

            component: {
                xtype: 'button',
                width: 57,
                height: 57,
                iconCls: 'add1',
                iconMask: true,
                handler: function () {
                    var gallery = Ext.getCmp('images-gallery');
                    if (!gallery) {
                        gallery = Ext.Viewport.add({
                            xtype: 'gallery',
                            id: 'images-gallery'
                        });
                    }
                    console.log(this.hasParent()); // FALSE

                    gallery.setIconButton(this);
                    gallery.show();
                }
            }
        }, {
            xtype: 'textfield',
            name: 'webClipImage[]',
            label: 'webClipImage'
        }]
    });

    console.log(webClip);
    console.log(webClip.query('.button'));
    Ext.getCmp('main-panel').add(webClip);
}

Console.log 结果:

Class {items: Class, _items: Class, innerItems: Array[9], onInitializedListeners: Array[0], initialConfig: Object…}

[Class]
> 0: Class
> length: 1
> __proto__: Array[0]
4

1 回答 1

1

这就是你如何找到你的按钮:

console.log(webClip.down('field[cls=icon-input]').component);
于 2013-05-24T16:19:33.303 回答