我尝试使用此代码
listeners : {
afterrender : function(comp) {
var countryValue = data.countryCode;
if (countryValue == "AU" && Ext.isEmpty(comp.getValue())) {
Ext.getCmp('state').markInvalid('When Country is AU, State is mandatory.');
Ext.getCmp('state').enable();
comp.inputValue = true;
} else {
comp.clearInvalid();
}
}
}
Run Code Online (Sandbox Code Playgroud)
状态字段最初是禁用的。只有当 country 字段取值为“AU”时,才需要启用 state 字段。
而不是 enable(),你需要给 setdisabled(false);
listeners : {
afterrender : function(comp) {
var countryValue = data.countryCode;
if(countryValue == "AU" && Ext.isEmpty(comp.getValue())){
Ext.getCmp('state').markInvalid('When Country is AU, State is mandatory.');
Ext.getCmp('state').setdisabled(false);
comp.inputValue = true;
}else{
comp.clearInvalid();
}
}
}
Run Code Online (Sandbox Code Playgroud)