Doubt in action script for Flex: getting unique elements from an ArrayCollection

Posted by Nirmal Singh Raja Reegan on Stack Overflow See other posts from Stack Overflow or by Nirmal Singh Raja Reegan
Published on 2010-03-19T05:27:04Z Indexed on 2010/03/19 5:31 UTC
Read the original article Hit count: 669

Hi,

I have an ArrayCollection as mentioned below.

        private var initDG:ArrayCollection = new ArrayCollection([
            {fact: "Order #2314", appName: "AA"},

            {fact: "Order #2315", appName: "BB"}

            {fact: "Order #2316", appName: "BB"}
                            ...

            {fact: "Order #2320", appName: "CC"}

            {fact: "Order #2321", appName: "CC"}

            ]);

I want to populate a ComboBox with UNIQUE VALUES of "appName" field from the ArrayCollection initDG.

<mx:ComboBox id="appCombo" dataProvider="{initDG}" labelField="appName"/>

One method I could think is to loop through the Array objects and for each object check and push unique appName entries into another Array. Is there any better solution available?

© Stack Overflow or respective owner

Related posts about flex

Related posts about arraycollection