简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM