1 Reply Latest reply on Sep 25, 2006 5:38 PM by ntsiii

    comboBox + value

    ljonny18 Level 1

      is it possible in Flex to add a value (id) to each individual row (item) within a comboBox?

      For example my comboBox is being populated from a DB table through a web service. The table consists of an ID field and the name field, and is relational to the rest of the database - so I want to display the name in the comboBox, but actually pass the ID integer across.....

      I am currently using the "labelFeild" to display the relevant column in the comboBox which works, but I additionally want to pass the ID across and through a function etc.....

      Any suggestions of the best way to do this?

        • 1. Re: comboBox + value
          ntsiii Level 3
          This is not a Flex Builder question. Next time post in the appropriate forum.

          The data provider for the combobox can be an object containing absolutely anything you want. In you case the dataProvider will probably be an array of objects, each item object with the properties id, and name.

          You use labelField to tell the combo which to display.

          When an item is selected, you can access any property of the selected item:
          var sIdSelected:String = myCombobox.selectedItem.id