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.

Share

About the Author

By day, Jeff Fox works as a senior software engineer at X Plus One and has 15 years of professional experience in the world of Web Development, Flash and design. By night, he is a husband and father of three amazing children, open source enthusiast, published comic book author, amateur writer and trained musician. Jeff makes him home with his family in Southern Connecticut.