Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select and remove items from dojo.form.Multiselect

I have two sets of dojo.form.Multiselect boxes on a Wizard Dialog. They have the ability to transfer items between them like this example: Testing Multiselect from Widget. I also have a checkbox on the form and when a user clicks on it, I need to:

  1. Select all items in the first Multiselect box
  2. Move them to the right side select box via addSelected()
  3. Clear the first list of all items

The invsertSelection option doesn't work because if any items are selected at the time the checkbox is clicked, only the unselected items are selected and moved. I don't see a way in the API to do this nor a reliable method in the codesphere. Any suggestions?

like image 508
JFOX Avatar asked Jan 19 '26 01:01

JFOX


1 Answers

Figured out a solution from looking at Dojo Docs and other code:

var selectItem1 = dijit.byId('firstSelectBox');

// Deselect all and invert to Select all
selectItem1.set("value",[]);
selectItem1.invertSelection();

//Move items to right box
var selectItem2 = dijit.byId('secondSelectBox');
selectItem2.addSelected(selectItem1);
like image 149
JFOX Avatar answered Jan 20 '26 15:01

JFOX



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!