我有一个值为'1,2,3,4,5 .... 13'的组合框
如果所选值为1,那么我必须在现有表单字段中显示3个字段。如果该值为2、3、4、5或6,那么我需要添加一个字段。
{
xtype:'combobox',
name:'user_role',
id : 'user_role',
fieldLabel: 'Role',
displayField: 'role_name',
valueField: 'role_id',
store: roleStore,
allowBlank: false,
queryMode : 'local'
},
显示/隐藏字段的代码:
created hideden fields like :
{
xtype: 'textfield',
fieldLabel: 'License Number',
name: 'doctor_licenseNumber',
id : 'doctor_licenseNumber',
//allowBlank: false,
enablekeyEvents: true,
hidden: true,
},
Ext.getCmp('user_role').on('change', this.onChange, this);
onChange: function(field, newValue) {
switch(newValue) {
case '1':
Ext.getCmp('doctor_type').show();
Ext.getCmp('doctor_licenseNumber').show();
Ext.getCmp('doctor_departmentId').show();
Ext.getCmp('marketing_allocationStatus').hide();
break;
case '2':
Ext.getCmp('marketing_allocationStatus').show();
Ext.getCmp('doctor_type').hide();
Ext.getCmp('doctor_licenseNumber').hide();
Ext.getCmp('doctor_departmentId').hide();
break;
default :
Ext.getCmp('doctor_type').hide();
Ext.getCmp('doctor_licenseNumber').hide();
Ext.getCmp('doctor_departmentId').hide();
Ext.getCmp('marketing_allocationStatus').hide();
}
},
它可以正常工作,但我还需要检查值“ 3,4和5”。我认为有适当的方法可以做到这一点。 “ 2、3、4和5”具有与“ parentId”相同的值。
请分享您的想法。
答案 0 :(得分:0)
假设您希望处理常见案件,则可以使用相同的逻辑绑定多个案件,如下所示:
如果case1和case2必须执行相同的功能,则可以按以下方式使用它:
Could not find a version that satisfies the requirement tensorflow (from
versions: ) No matching distribution found for tensorflow
根据您提供的描述,似乎您必须对案例2、3、4、5、6执行相同的功能。考虑到这一点,我对您的代码进行了如下修改:
case1:
case2:
//your code