首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取FieldSet的元素

如何获取FieldSet的元素
EN

Stack Overflow用户
提问于 2012-05-15 23:04:21
回答 2查看 5.6K关注 0票数 3

我有一个FieldSet:

代码语言:javascript
复制
Ext.define('admin.view.BuzzEditForm', {
    extend: 'Ext.form.Panel',
    requires: ['Ext.form.FieldSet','Ext.Img'],
    id: 'editorPanel',
    xtype: 'buzzEditForm',
    config: {
        /* modal: true,
         hideOnMaskTap: false,
         centered: true,
         width: 500,
         scrollable: false,*/
        items: [{
            xtype: 'fieldset',
            items: [
                {
                    xtype: 'textfield',
                    name: 'keyword',
                    label: 'Mots clés'
                },
                {
                    xtype: 'textfield',
                    name: 'title',
                    label: 'Titre'
                },
                {
                    id: 'editorPanelvisual',
                    xtype: 'field',
                    label: 'Visuel actuel',
                    component:
                    {
                        xtype: 'container',
                        layout: 'hbox',
                        items: [
                            {
                                id: 'buzzImageField',
                                flex: 1,
                                xtype: 'image',
                                src: 'http://pierre.chachatelier.fr/programmation/images/mozodojo-original-image.jpg',
                                height: 200
                            },
                            {
                                id: 'buzzChooseImageField',
                                xtype: 'button',
                                iconCls: 'arrow_right',
                                iconMask: true,
                                ui: 'action',
                                action: 'chooseBuzzImage'
                            }

                        ]
                    }

                },
                {
                    xtype: 'textfield',
                    name: 'visual',
                    label: 'Visuel'
                }
            ]
        }]
    }
});

我可以使用Ext.getCmp('#editorPanel')获取我的formPanel,但是如何使用字段的名称获取字段呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-05-15 23:07:06

只需使用Ext.ComponentQuery,例如:

Ext.ComponentQuery.query('textfield[name="keyword"]')

欲了解更多详情,请访问:http://docs.sencha.com/touch/2-0/#!/api/Ext.ComponentQuery

票数 4
EN

Stack Overflow用户

发布于 2012-12-11 22:38:52

顺便提一下,Ext.ComponentQuery.query('textfield[name="keyword"]')返回一个数组。因此,如果您只需要一个类似上面示例的元素,则必须使用.pop()函数来获取最后一个也是唯一一个元素,然后对其进行操作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10603594

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档