开发者

Flex: Bind values in a List with ComboBox as Item Renderer

I am using a List with an ArrayCollection as a DataPr开发者_如何学Goovider. 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.


We ended up making our own component: CheckboxList

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜