1 Reply Latest reply on Jul 27, 2007 4:18 PM by ntsiii

    Use only unique values as combo box data provider.

    Level 7
      I have an array collection of objects each of which has a property I
      will simply call 'name'. Let us say that this array collection contains
      a list of objects with the following name values
      ['George','Fred','George','Ron','Bill','Charlie','Bill','Bill','Percy'].

      I would like to use these names as the data provider of a combo box, but
      without the duplicates. What would be the easiest way to distill this
      down to an array of unique values to use as this combo box's data
      provider in Flex?

      The original array collection was the result of an remote object call to
      a cfc that returned a record set from a data store. Is it a better
      option to create a new function in this cfc that returns the unique list
      I desire, or can I do this easily inside the Flex code since I already
      have the complete list?

      TIA
      Ian Skinner
        • 1. Re: Use only unique values as combo box data provider.
          ntsiii Level 3
          Untested:
          var aData:Array = ['George','Fred','George','Ron','Bill','Charlie','Bill','Bill','Percy'];
          var oCheck:Object = new Object():
          var aUnique:Array = new Array()
          var sValue:String
          for (vari:int=0;i<aData.length;i++) {
          sValue = aData[ i ];
          if (!oCheck[sValue ]) { //is this a unique value?
          oCheck[sValue ] = true; //put this value in the check object
          aUnique.push(sValue)
          }
          }

          Note: if the values contain illegal property name values, yo would need to modify this.

          Tracy