3 Replies Latest reply on Nov 15, 2009 12:49 PM by Yannis Develekos

    Interesting, almost necessary.

    Yannis Develekos Level 1

      I just came across this usefull example http://blog.rotundu.eu/wp-content/uploads/goodies/ACESample/bin-release/ACESample.html but I have a question. Let’s say that we need the comboboxes on the example to be dynamically populated back from the filtered arrayCollection. For example when you move the right thumb to narrow down the price, after a little while you are left with “computers” and “electro” type of items only. It would be appropriate if the values of the corresponding combobox would be narrowed down automatically (at the same time), so that when the user clicked on it she would see on the list only “computers” and “electro” values available. Is this possible?



        • 1. Re: Interesting, almost necessary.
          Subeesh Arakkan Level 4



          Change the combobox dataproviders to arraycollection and apply filterFunctions.

          • 2. Re: Interesting, almost necessary.
            Yannis Develekos Level 1

            Thank you Subeesh,

            Yes, I guess theoritically the solution you suggest is the obvious one but I have another problem I cannot figure out how to overcome. If you run the example above and grab the right thumb and move it all the way to the left you are left with three items only. If you take a look you will see that the type column has the "computer" type once and the "electro" type twice. So if I populate the combobox with this information the "electro" type will appear twice and this is inappropriate. My question is how do I filter in Flex the column and present only dinstict values, as you would accomplish using the DINSTICT command in SQL (take a look at this example http://www.sql-tutorial.com/sql-distinct-sql-tutorial/. This is exactly what I want to accomplish in Flex with my arrayCollection).

            And you can understand the real need when I have to filter an arrayCollection with 3.000 properties or more where a single area or city whould appear hundrends of times. I want to present this only once in the combobox.


            Any ideas on this?


            Thank you in advance,


            • 3. Re: Interesting, almost necessary.
              Yannis Develekos Level 1

              I found the solution. http://blog.flexguru.nl/2009/09/retrieving-distinct-property-values-from-an-array-of-objec ts/ did it! The code I ended up using follows below. Thanks for your attention. Hope this helps.


              //create the var to hold the Location values in the result array


              private var distinctValuesCollection:ArrayCollection = new ArrayCollection();


              //call the function to retreive dinstinct Location values

              distinctValuesCollection = getDistinctPropertyValues(ourProperties,



              //get dinstinct values from the ourProperties arrayCollection

              //sort them and fill the comboBox

              private function getDistinctPropertyValues(collection:ArrayCollection, propertyName:String):ArrayCollection {

              //prepare result array

              var distinctValuesCollection:ArrayCollection = new ArrayCollection();

              //prepare a temp working array

              var tempPropertyArray:Array = [];


              //loop over all the objects in the collection

              for each (var object:Object in collection) {

              //get the property value from the object

              var propertyValue:Object = object[propertyName];


              //write the value as a property

              tempPropertyArray[propertyValue] = true;



              //loop over all the properties in the tempPropertyArray

              for (var propertyName:String in tempPropertyArray) {

              //add the propertyName (which is actually a distinct property value)

              //to the distinct values collection



              //sort it in descending order

              //create sort order

              var sortColl:Sort = new Sort();

              sortColl.fields=[new SortField()];

              // sort it!


              //refresh the collection to be actually sorted



              //return the collection of distinct values

              return distinctValuesCollection;