views:

86

answers:

2

Hi,

How would I get a drop downlist to populate with check boxes. I am porting a c# project to flex, and I would like to imitate the functionality of their checkbox drop list.

Anyone got any idea how I would go about this.

Please and thank you.

A: 

you could extend the popup-button and add custom item renderer for the items in the dropdown.

http://www.adobe.com/livedocs/flex/2/langref/mx/controls/PopUpButton.html

Adrian Pirvulescu
Do you by any chance have an example of the code required to do this.And to return the selected items?
Craig Mc
The above is specific to the halo PopUpButton. The original question refers to the spark DropDownList component. I would recommend looking at the docs for the latter instead.
Wade Mueller
@Wade yes! you are right. in spark you need DropDownList. @Craig Please check the itemRenderer examples for lists and see how stuff is done in there. I am sorry I do not have an example of it
Adrian Pirvulescu
Hi what I did in the end was I simply used a combolist with itemrendere set to the checkbox control this worked :)
Craig Mc
There is an addendum to this problem, I cant actually click the check boxes.. the moment one does the dropdownlist closes.
Craig Mc
http://www.blastanova.com/blog/2010/06/23/a-custom-multi-selection-spark-dropdownlist/ <= found this however I am strugling to see how to get the final array of selected checkboxes back out of it.
Craig Mc
1. for combobox selection. you should have a "selected" inside the object data you pass to the combobox, and assign the selected property as checkbox.selected property. 2. for the problem with autocosing when clicking a checkbox, you should be able to prevent closing of the checkbox by overriding the checkbox class.
Adrian Pirvulescu
+1  A: 

Typically you do this by creating a custom ItemRenderer and assigning it to your DropDownList. Here's an example of creating/applying a custom ItemRenderer in a DropDownList:

http://blog.flexexamples.com/2010/05/13/setting-the-text-roll-over-color-on-a-spark-dropdownlist-control-in-flex-4/

Hope that helps.

Wade Mueller
I just specified mx.controls.checkbox as the renderer that worked great thanks :)
Craig Mc