Question

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); ??
}
Was it helpful?

Solution

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();

});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top