Flex: Bind values in a List with ComboBox as Item Renderer
I am using a List with an ArrayCollection
as a DataProvider
. The list uses ComboBox
as Item Renderer
itemRenderer="mx.controls.CheckBox"
I would like to bind the values in the List.
You have a list with several comboboxes, and those values are loaded dynamically from an ArrayCollection
.
The ArrayCollection
contains Objects with a boolean property for which I should bind the True/False values selected in the comboboxes
.
Make something like this:
<?xml version="1.0" encoding="utf-8"?>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import spark.events.IndexChangeEvent;
[Bindable]
private var myAC:ArrayCollection = new ArrayCollection(["True","False"]);
[Bindable]
public var editorSelectedIndex:int;
protected function changeHandler(event:IndexChangeEvent):void
{
data.selectedIndex = event.target.selectedIndex;// TODO Auto-generated method stub
}
]]>
</fx:Script>
<s:RichText color="#2B4381" text="{data.name}" left="0" top="0" width="190" height="100%"/>
<s:ComboBox dataProvider="{myAC}" selectedIndex="{data.selectedIndex}" change="changeHandler(event)" left="200" top="0" height="100%"/>
Basically you can write back to the "data" property with your new data. Hope this helps.
我们最终创建了自己的组件:CheckboxList
链接地址: http://www.djcxy.com/p/34578.html上一篇: Flex可编辑组合框