首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在EXT JS 4中获取字段容器的子项

在EXT JS 4中获取字段容器的子项
EN

Stack Overflow用户
提问于 2013-01-24 01:06:10
回答 3查看 3.7K关注 0票数 1

我有一个简单的问题,尽管它让我很头疼。

我有一个字段容器,其中添加了一些单选字段:

代码语言:javascript
复制
xtype      : 'fieldcontainer',
                            fieldLabel : 'Field type',
                            defaultType: 'radiofield',
                            defaults: {
                                flex: 1
                            },
                            items: [
                                {
                                    boxLabel  : 'Plain Text',
                                    name      : 'plain-text',
                                    inputValue: 'plain-text',
                                    id        : 'plain-text'
                                }, {
                                    boxLabel  : 'Rich Text',
                                    name      : 'html-text',
                                    inputValue: 'html-text',
                                    id        : 'html-text'
                                }, {
                                    boxLabel  : 'Time',
                                    name      : 'time',
                                    inputValue: 'time',
                                    id        : 'time'
                                },
                                {
                                    boxLabel  : 'Typed reference',
                                    name      : 'typed-reference',
                                    inputValue: 'typed-reference',
                                    id        : 'typed-reference'
                                },
                                {
                                    boxLabel  : 'Date',
                                    name      : 'date',
                                    inputValue: 'date',
                                    id        : 'date'
                                }

                            ],

                            listeners: {
                                added: function(radiofield) {
                                    ??

                                }

我尝试了几乎所有检查radiofield对象的方法,比如迭代添加项的items.items数组,但是,我只得到项的整数值,而不是对象本身。我想迭代添加到容器中的所有项,以便在满足特定条件的单选字段上设置一个校验值。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-01-24 01:10:38

使用query([selector])

检索与传递的选择器匹配的所有子组件。使用此容器作为其根来执行Ext.ComponentQuery.query。

票数 0
EN

Stack Overflow用户

发布于 2013-01-25 17:27:59

你不使用RadionGroup有什么原因吗?不管怎样,Items的类型是Ext.util.MixedColletion,它为您提供了每个方法的http://docs.sencha.com/ext-js/4-1/#!/api/Ext.util.AbstractMixedCollection-method-each

请尝试以下操作

代码语言:javascript
复制
// define a function within the scope of the fieldcontainer(instance)
handlerFunction: functio(item) {
    // item is the instance of your radiofield
    // you can access any property or call any method
    if (item.name === 'html-text') {
         item.setValue('html-text');
    }
}

fieldcontainerInstance.items.each(handlerFunction,handlerFunctionScope);
票数 0
EN

Stack Overflow用户

发布于 2014-12-30 17:51:02

只需输入item.query()即可获取它所拥有的所有项。

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

https://stackoverflow.com/questions/14485306

复制
相关文章

相似问题

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