Now let’s see how you can create MultiSelect dropdown in your own aura component by using the above component.
Note: Make sure you have downloaded above component and added it in your org before you use it.
To use the above component, we will create a new component and will pass the options list to the MultiSelect component.
MultiSelectUsageDemo Component
https://gist.github.com/a5b4db94fd4e85dedf4cc2838e622666
MultiSelectUsageDemo JS Controller
https://gist.github.com/727537b624a03eda76e46c40663a24ac
Shyam Nair
2 May 2019Good work!! This will really come handy!!
Pingback: Color Columns of Lightning Data Table - LWC - SFDCFacts
Brian
10 Jun 2019This is a great! Thank you for sharing. I have a question — or maybe a few … In the MultiSelect.cmp around like 68 you have the id=”listbox-option-unique-id-01″ — this is inside iteration. Should that be truly unique?
Manish Choudhari
11 Jun 2019No really!! We are not using that Id anywhere.
It’s my mistake that I haven’t removed it.
You may have the same id for all list items or you may remove it completely as it won’t affect the component.
Brian
11 Jun 2019Thank you — I’m curious, what action on the page do use you to fire the actual filtering of data? It isn’t a variable on the component, are you simply adding some code to the onInputChange event?
Brian
11 Jun 2019I guess maybe to be more specific — if the MultiSelect Component is a child, and the parent has the data to be filtered, how are you firing that event back on the parent? I hope that makes sense. Thank You!
Eric Soraya
3 Jul 2019This helped me a bunch I had to Wire it up to an existing component I had but after much debugging it seems to be implemented and working correctly. I had to tweak the Helper to grab the list and sent it to a registered event so that I could get the value in the Parent Component. And and a separate function to get the actual value that was clicked as opposed to the selectedOptions.Length + ‘Options Selected’
Thank you for the knowledge as it would have taken me a lot longer to build this from scratch.
Mukesh Saxena
20 Sep 2019It is really good. Thanks for the sharing.
J Watson
22 Oct 2019Hi Manish, the component is great and has saved so much time already. My current use case for this, however, is to allow the user to select some options in the list, they can then leave the page and return at a later date (the selected options are saved). I am having difficulty however setting the previously selected values as the component loads… Do you have any advice on how this is to be achieved? Many thanks in advance