Hi,
I have a webdropdownlist of lets say 5 items
First item is ALWAYS empty (Key = -1, text = "")
the other items, are not (of course)
my dropdown is defined by
What I'm trying to achieve, in JS, is
Sorry for the weird question perhaps.
Hi there Razieltje,
Take a look at the following forum thread: http://forums.infragistics.com/forums/t/55898.aspx
It deals with pretty much the same thing, except in this case it is checkboxes and you want to work with the selection. All you have to change in that example is to hook to selection changing and if the newly selected item is the first one to loop through all the rest and unselect them, otherwise to get the first item and unselect it. This is done through set_selected(boolean).
I hope this would do the job!
First of all , thanks for the reply.
My code, being based on that post. Seems to always return the first item (being the empty item - autoselected- and the new selected item, resulting in nothing changing.(because he loops through it first..?
What seems to be wrong? (this is called in the selectionChanging..
function CheckAllCheckboxes(sender, eventArgs) { if (eventArgs.getNewSelection().length == 0) { sender.get_items().getItem(0).set_selected(true); sender.get_items().getItem(0).select(); sender.get_items().getItem(0)._element.childNodes[0].checked = true; for (var i = 1; i < sender.get_items().getLength(); i++) { sender.get_items().getItem(i).set_selected(false); sender.get_items().getItem(i).unselect(); sender.get_items().getItem(i)._element.childNodes[0].checked = false; } } else { if (eventArgs.getNewSelection()[0]._address && eventArgs.getNewSelection()[0]._address == 0) { for (var i = 1; i < sender.get_items().getLength(); i++) { sender.get_items().getItem(i).set_selected(false); sender.get_items().getItem(i).unselect(); sender.get_items().getItem(i)._element.childNodes[0].checked = false; } } else { sender.get_items().getItem(0).set_selected(false); sender.get_items().getItem(0).unselect(); sender.get_items().getItem(0)._element.childNodes[0].checked = false; } } return true; }
Yeah that doesn't quite work. Here is what I have that worked for me:
function CheckAllCheckboxes(sender, eventArgs) { if (eventArgs.getNewSelection()[eventArgs.getNewSelection().length - 1]._address && eventArgs.getNewSelection()[eventArgs.getNewSelection().length - 1]._address == 0) { for (var i = 1; i < sender.get_items().getLength(); i++) { sender.get_items().getItem(i).unselect(); sender.get_items().getItem(i)._element.childNodes[0].checked = false; } } else { sender.get_items().getItem(0).unselect(); sender.get_items().getItem(0)._element.childNodes[0].checked = false; }}
Try it and let me know if you need anything else!
Thank you for using the Infragistics forums!
Thanks, seems to do what it needs to do in my case :)