[英]Show hide elements in extjs
I'm trying to show and hide radiogroups, based on selection from a drop-sown selection. 我试图根据从播种的选择中选择来显示和隐藏广播组。 So that if i choose toshiba only the toshiba models appear, else if i choose hp only the hp models appear. 因此,如果我选择东芝,则只会出现东芝型号,否则,如果我选择马力,则只会出现hp型号。 Now the functionality is working, however at the beginning before selecting anything, both models (hp and toshiba) are showing, however i want it so that only the toshiba models are showing at the beginning. 现在该功能正常运行,但是在开始选择任何东西之前,两种型号(hp和toshiba)都在显示,但是我想要它,以便仅在开始时显示toshiba型号。 I tried giving the hp models, the property hidden:true..But when selecting hp, the models no longer appear. 我尝试给hp模型提供了属性hidden:true。。但是选择hp时,模型不再显示。 Any idea on how to display only one model at the beginning? 关于在一开始只显示一个模型的任何想法?
toshibatypes = Ext.create('Ext.form.Panel', {
xtype: 'radiogroup',
defaultType: 'radio',
layout: 'hbox',
border:false,
id: 'toshiba',
width:'100%',
items: [
{
checked: true,
boxLabel: 'Toshiba 1',
name: 'toshibas',
inputValue: 'toshiba1',
xtype:'radiofield'
},
{
boxLabel: 'Toshiba 2',
name: 'toshibas',
inputValue: 'toshiba2',
xtype:'radiofield'
}
]
});
hptypes = Ext.create('Ext.form.Panel', {
xtype: 'radiogroup',
defaultType: 'radio',
layout: 'hbox',
border:false,
id: 'hp',
width:'100%',
items: [
{
checked: true,
boxLabel: 'HP 1',
name: 'hps',
inputValue: 'hp1',
xtype:'radiofield'
},
{
boxLabel: 'HP 2',
name: 'hps',
inputValue: 'hp2',
xtype:'radiofield'
}]
});
laptoptypes = Ext.create('Ext.form.ComboBox', {
store: laptops,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
editable:false,
width: 100,
listeners: {
select: function() {
var iComboValue = laptoptypes.getValue();
switch(iComboValue) {
case "toshibatypes" :
{
Ext.get("toshiba").show();
Ext.get("hp").hide();
break;
}
case "hptypes" :
{
Ext.get("hp").hide();
Ext.get("toshiba").show();
break;
}
}
}
}
});
If you configure hidden on the view declaration you can use setHidden( boolean )
. 如果在视图声明中配置了hidden,则可以使用setHidden( boolean )
。
var iComboValue = laptoptypes.getValue();
Ext.get("toshiba").setHidden(iComboValue !== 'toshibatypes');
Ext.get("hp").setHidden(iComboValue !== 'hptypes');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.