【问题标题】:want to enable a combobox only when another combo is selected in extjs仅当在 extjs 中选择了另一个组合时才想启用组合框
【发布时间】:2015-02-12 07:51:48
【问题描述】:

有两个组合框和一个按钮。我想要一个验证,即如果选择了“combo1”,那么应该启用“combo2”,当我选择“combo2”时,应该启用浏览按钮。

【问题讨论】:

  • 到目前为止你有没有编写任何代码?

标签: extjs extjs4.2 extjs-mvc


【解决方案1】:

类似的东西(在第一个组合框上插入文本):

combobox2 和按钮必须有这样的配置:

hidden:true,
disabled:true,

在组合框 1 上:

listeners:{

change: function(combobox,newValue, eOpts){

 var combo2 = Ext.ComponentQuery.query('#combo2ItemId')[0];
 var button = Ext.ComponentQuery.query('#buttonItemId')[0];

 if(!Ext.isEmpty(newValue)) {
    combo2.setHidden(false).setDisabled(false);
    button.setHidden(true).setDisabled(true);
    }
 else {
    combo2.setHidden(true).setDisabled(true);
    button.setHidden(true).setDisabled(true);
    }
}

在组合框2上:

listeners:{

change: function(combobox,newValue, eOpts){

 var button = Ext.ComponentQuery.query('#buttonItemId')[0];

 if(!Ext.isEmpty(newValue)) {
    button.setHidden(false).setDisabled(false);
    }
 else {
    button.setHidden(true).setDisabled(true);
    }
}

我希望这会有所帮助!

【讨论】:

  • 感谢您的帮助@josei
【解决方案2】:

我猜你可能想在页面首次显示时禁用第二个组合和按钮。

然后您可以侦听每个组合的更改事件,并在您的处理程序代码中禁用\启用您需要根据传递给处理程序函数参数的值进行控制。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-22
    • 1970-01-01
    • 2016-07-13
    • 1970-01-01
    • 2016-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多