0

Why don’t Dojo SelectBoxes have a “Select All” function?

It’s kind of annoying to me that Dojo SelectBoxes do not have the ability to select all items with a single function call. It’s kind of strange. I can understand their connection to data stores to keep the data, but how can they not have selectBox.selectAll()?

To have the ability to select all items and clear a select box that swaps selected items with a second right hand select box, I had to use the following semi-convoluted 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);

I guess we could make our own custom extension of the class, but seems like it should already be in there. maybe it’s a deliberate decision of the Dojo team. Just odd.

jfox015

Jeff Fox is an almost twenty year web front end/ digital user experience technology leader. He cut his teeth in the web's early days and has worked for fortune 100 companies, small startup agencies and several companies in between. In addition to being a passionate developer and technical speaker, Jeff is a dedicated tech and sci-fi geek gladly indulging in Doctor Who and Star Wars marathons. He is also a talented musician, writer and proud father of three little Foxies. And don't get him started about his San Francisco Giants.

Leave a Reply

Your email address will not be published. Required fields are marked *