Dojo dynamic loading widget DropDownSelect

I have two DropDownSelect widgets added to mine from what I need - to load data dynamically in the second DropDownSelect widget, since the first DropDownSelect widget changes the way data is loaded into the DropDownSelect widget programitacally.

Abdul Khalik

+3
source share
2 answers

I think you need something like this:

      dojo.connect(s1, 'onChange', function(value) {

      console.log(value); // selected in s1 value

      s2.addOption([{ 
        label: "new option1", value: 1
      },
      { 
        label: "new option2", value: 2
      },
      { 
        label: "new option3", value: 3
      }]);
    });

In this example above, when the selected value of s1 changes, we load 3 new parameters into s2. You can only pass one option to the addOption method instead of an array:

    s2.addOption({ label: "new option1", value: 1 }

You might also want to clear s2 first:

    s2.options = [];
+5
source

DropDownSelect onChange, , , - addOption:

var s1 = new dojox.form.DropDownSelect();
var s2 = new dojox.form.DropDownSelect();
s1.onChange(function() {
  s2.addOption(new Option("text","value"));
});
+1

Source: https://habr.com/ru/post/1721409/


All Articles