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:
- Select all items in the first Multiselect box
- Move them to the right side select box via addSelected()
- 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?
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:
- Select all items in the first Multiselect box
- Move them to the right side select box via addSelected()
- 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?
Share Improve this question asked Jun 8, 2012 at 14:48 JFOXJFOX 2451 gold badge6 silver badges15 bronze badges2 Answers
Reset to default 4Figured 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);
Basically the addSelected does a dom query on the select to see which options are marked as selected :
query("option",this.containerNode).filter(function(n){
return n.selected; // Boolean
});
so you could basically select everything by doing :
query("option", myMultiSelect.containerNode).forEach(function(n){
n.selected = true; // Boolean
});
then use addSelected... somethign like that should do the trick.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744707313a4589131.html
评论列表(0条)