Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何根据ExtJs中的某些条件启用禁用的textfield?_Extjs - Fatal编程技术网

如何根据ExtJs中的某些条件启用禁用的textfield?

如何根据ExtJs中的某些条件启用禁用的textfield?,extjs,Extjs,我试着使用这个代码 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.

我试着使用这个代码

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();
    }
  }
}
状态字段最初被禁用。只有当country字段的值为“AU”时,才需要启用state字段。

而不是enable(),您需要为setdisabled(false)

如果您看到textfield的enable方法是可更改的,并且“传递true将禁止激发enable事件”。我们不能仅仅通过传递
enable()
来启用它,因为它需要布尔值才能使其工作。因此,您的行
Ext.getCmp('state').enable()不工作

是,您有
setDisabled(false)
,这可以使该值启用

你的电话号码是

Ext.getCmp('state').setDisabled(false);

方法名称中有输入错误,它必须是
setdiasled
Ext.getCmp('state').setDisabled(false);