Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dojo dynamically loading DropDownSelect widget

I have two DropDownSelect widgets added to my from what i need is to dynamically load the data in the second DropDownSelect widget as the first DropDownSelect widget changes how can i load the data in DropDownSelect widget programitacally.

Abdul khaliq

like image 589
Abdul Khaliq Avatar asked Nov 25 '25 01:11

Abdul Khaliq


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 selected value of s1 changes, we load 3 new options into s2. You can pass only one option to addOption method instead of array:

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

Probably, you also wish to clear s2 first:

    s2.options = [];
like image 141
ivalkeen Avatar answered Nov 27 '25 13:11

ivalkeen


DropDownSelect has an "onChange" method which you can pass an anonymous function that builds the option list for the second select using something like addOption:

var s1 = new dojox.form.DropDownSelect();
var s2 = new dojox.form.DropDownSelect();
s1.onChange(function() {
  s2.addOption(new Option("text","value"));
});
like image 27
TML Avatar answered Nov 27 '25 13:11

TML



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!