[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

arrayCollection Grouping for comboBox

Posted on 2011-03-14
1
Medium Priority
?
558 Views
Last Modified: 2012-08-13
How to group items in an array collection so my combobox does not repeat the duplicat items. I have don this with a datagrid but can not seem to get to work with a combobox.
0
Comment
Question by:kpjj31
1 Comment
 
LVL 29

Accepted Solution

by:
dgofman earned 2000 total points
ID: 35134376
You may not need to use a groupCollection,
You can use an Array filter.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" initialize="init()">
	<fx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;

			private var _original:Array = new Array(
					{label:"One", data:1},
					{label:"Two", data:2},
					{label:"Three", data:3},
					{label:"One", data:1}
			);
			
			private function init():void{
				var keys:Object = {};
				var filteredArr:Array = _original.filter(function(item:Object, idx:uint, arr:Array):Boolean {
					if (keys.hasOwnProperty(item.data)) {
						return false;
					} else {
						keys[item.data] = item;
						return true;
					}
				});
				cmb_uniq.dataProvider = new ArrayCollection(filteredArr);
			}
		]]>
	</fx:Script>
	<s:ComboBox id="cmb_uniq"/>
</s:Application>

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question