AnsweredAssumed Answered

How to create multi select dropdown

Question asked by Bleroux on Aug 9, 2019
Latest reply on Aug 19, 2019 by Bleroux

So I was trying to create a regular dijit/form/MultiSelect but can't seem to get it to populate any values using JS. As I was looking for examples in other wigets I notice the query widget has a nice multi select drop down widget. This would fit my needs much better. Anyone have any knowledge on how to create this?

 

 

If not I will keep trying to get my regular multiselect working.

 

function(response) {                 
                         let option;
                         let optionsArray = [];
                         
                                        
                         
                         for (let i = 0; i < response.features.length; i++) {
                              switch (selectField) {
                                   case "capCat":
                                        option = {value: [response.features[i].attributes.CAT_No, response.features[i].attributes.CAT_Begin_Dt, response.features[i].attributes.CAT_End_Dt], label: response.features[i].attributes.CAT_Full_Name};;
                                        optionsArray.push(option);
                                        break;
                                   case "capPeril":
                                        option = {value: response.features[i].attributes.COVERAGE, label: response.features[i].attributes.COVERAGE};;
                                        optionsArray.push(option);
                                        break;
                              }
                                   
                         }
                         //Use this if regular select
                         if (selectField == "capCat" ){
                              // Add a defualt option first
                              let option1 = { value: "-", label: "Select a " + title, selected: true };
                              select.addOption(option1);
                              //Then add the rest of the options
                              select.addOption(optionsArray);
                         } else { //use this if multiselect
                         //Attempt to load using store/Memory
                         
                         select.set("store", new Memory({data: optionsArray, idProperty: "value"}));
                         select.set ("labelAttr", "label");
                         console.log(select);
                         }

Outcomes