Extjs4 获取EXT JS 4中字段容器的子级
我有一个简单的问题,尽管这让我很头疼 我有一个字段容器,其中添加了一些无线电字段:Extjs4 获取EXT JS 4中字段容器的子级,extjs4,Extjs4,我有一个简单的问题,尽管这让我很头疼 我有一个字段容器,其中添加了一些无线电字段: xtype : 'fieldcontainer', fieldLabel : 'Field type', defaultType: 'radiofield', defaults: {
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数组以获取添加的项,但是,我只得到项的整数值,而不是对象本身。我想迭代添加到容器中的所有项目,以在符合特定条件的无线字段上设置选中值。使用
检索与传递的选择器匹配的所有子体组件。
使用此容器作为其根执行Ext.ComponentQuery.query
你为什么不使用RadionGroup?无论如何项的类型为Ext.util.MixedCollection,它为您提供了每个方法 试试下面的方法
// 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);
只需键入item.query()即可获得它拥有的所有项。我喜欢CD的答案,因为它实现起来很快。谢谢你的评论!你说得对,我把它改成了RadioGroup——这更有意义。