我有一个简单的问题,尽管它让我很头疼。
我有一个字段容器,其中添加了一些单选字段:
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数组,但是,我只得到项的整数值,而不是对象本身。我想迭代添加到容器中的所有项,以便在满足特定条件的单选字段上设置一个校验值。
发布于 2013-01-24 01:10:38
使用query([selector])
检索与传递的选择器匹配的所有子组件。使用此容器作为其根来执行Ext.ComponentQuery.query。
发布于 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
请尝试以下操作
// 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);发布于 2014-12-30 17:51:02
只需输入item.query()即可获取它所拥有的所有项。
https://stackoverflow.com/questions/14485306
复制相似问题