我试图选择位于面板中的多个对象(2个标签& 2 textfields)。我给了这些组件一个属性(changeVisibility:true)。Extjs 4中的组件选择器
所以我在这里试图完成的事情非常简单:当用户选中复选框时,具有属性(changeVisibility:true)的所有组件都应该变为不可见。所以在我的控制器中,我试图选择这些组件,但我无法完成这个目标。
非常感谢帮助!我的面板
代码:
Ext.define('Edocs.view.wizard.card-2.content.mobile-password.Panel', {
extend : 'Ext.FormPanel',
alias : 'widget.mobilePassword',
layout : {
type : 'vbox',
pack: 'center'
},
bodyStyle:{"background-color":"beige"},
border:false,
defaults:{
width: '100%'
},
items: [{
xtype : 'checkboxfield',
boxLabel : 'Enable mobile (iphone) accesibility',
boxLabelAlign : 'before',
name : 'enableMobile',
inputValue : '1',
id : 'cbxMobile',
itemId : 'cbxMobile'
},{
xtype: 'label',
text: "Please enter a password to connect to the platform by mobile (iphone/ipad)",
style: 'font-weight:bold;',
changeVisibility :true
},{
xtype: 'textfield',
name: 'mobilePassword',
id: 'txtMobilePassword',
inputType: 'password' ,
changeVisibility :true
//width: '100%'
},{
xtype: 'label',
text: "Confirm password",
style: 'font-weight:bold;',
changeVisibility :true
},
{
xtype: 'textfield',
name: 'mobilePasswordConfirm',
itemId: 'txtMobilePasswordConfirm',
inputType: 'password' ,
vtype: 'password',
initialPassField: 'txtMobilePassword',
changeVisibility :true
}],
initComponent : function() {
Ext.apply(this, {})
this.callParent(arguments);
}
});
这是在我的控制器功能(该功能被称为上的复选框的更改事件):我遇到麻烦
addMobilePassword : function(checkbox) {
var items = checkbox.up().down('mobilePassword[changeVisibility=true]');
if (checkbox.checked){
for (var i in items){
items[i].setVisible(false);
}
}
}
这个选择器:
var items = checkbox.up().down('mobilePassword[changeVisibility=true]');
如果任何人都可以给我一些关于如何选择的建议e组件。
谢谢!
你试过[checkbox.up().query( 'mobilePassword [changeVisibility =真]')](HTTP://文档.sencha.com/EXT-JS/4-0 /#!/ API/Ext.container.AbstractContainer法查询)? – 2012-04-25 08:47:23
刚刚尝试过,并没有工作... – Fbo 2012-04-25 08:55:24
我知道,如果组件只会是标签,这应该工作:var items = checkbox.up()。down('label [changeVisibility = true]'); – Fbo 2012-04-25 08:58:25