I have a WebDropDown populated at the server, and would like to client-side set or clear the checkbox on a particular item
<ig:WebDropDown ID="MyDropDownControl" runat="server" DisplayMode="DropDownList" EnableMultipleSelection="True" MultipleSelectionType="Checkbox" />
var ctrl = $find('MyDropDownControl');
var item0 = ctrl.get_items().getItem(0);
// these next two statements do select/unselect
// but no effect to the checkbox
item0.select();
item0.unselect();
// this does set the checkbox, but seems rather dangerous
item0.get_element().childNodes[0].checked = true;
Thank you!
Hi,
I tried your sample and it works fine - how i do it: select a few items (check them with the mouse), then click on "Clear using Nodes[0]", and then open the dropdown again - items are unckecked.
About textbox contents being not modified - this is the correct behavior. When items are selected, and there is multiple selection enabled, we do not update the contents of the text input - since this is done programatically. That's only done when selection is done through user interaction.
One can easily update the text input in the following way - for every item that is selected, append its text to some comma delimited string, and at the end do : dropDown.set_currentValue(selectedItemsString, true);
Thanks,
Angel
I'd meant Textbox contents does not change (not Checkbox)
Angel,
Sorry, the childNodes[1] had no effect in Firefox 3.0.11
I've determined the actual condition that is causing the issue in Firefox is after a post-back
I've attached a sample project illustrating the problem (minus the ig_res/images)
1. Check any item in the WebDropDown using IE8 or FF 3.0.11
2. Click the "PostBack" button
3. Click the "Clear w/Node[0]"
4. Observe: the checkbox is cleared in IE8, not cleared in FF
5. Repeat steps 1 and 2
6. Click the "Clear w/Node[1]"
7. Observe: the checkbox is not cleared in IE8, and not cleared in FF
8. Also observe, the attached checkbox contents do not change (whereas the contents does change when the checkboxes are checked/unchecked via mouse-clicks)
Yep, you are right. Firefox (also Chrome) doesn't contain the checkbox element in the childNodes[0], but a "\n". The checkbox is in childNodes[1].
Hope this helps,
Angel -
item0.get_element().childNodes[0].checked = false;
The above statement does not work in Firefox 3.0.11What would you suggest I do since there is not an IG method available to accomplish this