如何在dijit.form.Select中禁用单个选项? [英] How to disable a single option in a dijit.form.Select?
问题描述
我使用 dijit.form.Select
创建了2个Dojo下拉列表,我正在填充2个ArrayLists。当用户从第一个下拉列表中选择一个选项时,我希望第二个下拉列表中的一个选项被禁用。我似乎无法弄清楚如何做到这一点。是否可以通过编程方式从下拉列表中禁用单个选项?
这样的东西...
I created 2 Dojo dropdowns using dijit.form.Select
that I am populating with 2 ArrayLists. When a user selects an option from the 1st dropdown, I would like an option in the 2nd dropdown to disable. I can't seem to figure out how to do this. Is it possible to disable a single option from the dropdown programatically?
Something like...
if(this.dropDown1.get("value") == "FirstOption") {
//this.dropDown2.get("value", "AnotherOption").set("disabled", true); ??
}
推荐答案
尝试检索您的价值想要从dropDown2,并将其禁用的属性设置为true,直接(没有设置器,它只是一个简单的JavaScript对象)。然后调用dropDown2.startup()来在UI上进行更改。示例:
Try to retrieve the value you want from dropDown2, and set its disabled property to true, directly (there is no setter, it's just a plain javascript object). Then call dropDown2.startup() to make the changes on the UI. Example :
require(["dojo/_base/array"],
function(array) {
var self = this,
opt = array.filter(
self.dropDown2.options,
"return item.value == '" + self.dropDown2.get("value") + "'"
).pop();
opt.disabled = true;
this.startup();
});
这篇关于如何在dijit.form.Select中禁用单个选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!