如果是xtype:field的组件,.down()或.query()将找不到子项

时间:2013-02-15 15:28:32

标签: extjs sencha-touch sencha-touch-2

在这个简短函数的最底部,您可以看到我正在尝试获取xtype: button中的所有webClip。由于某种原因,它省略了57x57按钮并仅显示titlebar中的删除按钮。我无法弄清楚为什么。这个xtype: field的{​​{1}}配置对我来说相当混乱。谢谢!

component

Console.log结果:

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);
}

1 个答案:

答案 0 :(得分:1)

这就是你找到按钮的方法:

console.log(webClip.down('field[cls=icon-input]').component);