Question

I'm new to flex/flash builder, i need to read in data from a text document, then slice it into pieces i set out in my custom class.

all of this so far worked

var theCustomer:Customer=new Customer(name,address,phoneNo,comment,custNo);
custArray.addItem(theCustomer);

So now what i want to do is display only the name from each entry of the array into a combobox - and then on close it will display all the details into a list box

If i just bind the custArray to the combobox it displays name:address:phoneNo:comment:custNo as i set it out, but like i said i want only the name so how do i separate the name from each Customer entry in the array ??

Any help you be awesome and thanks in advance !!!

Was it helpful?

Solution

If I'm understanding your question correctly, I think you want to set the labelField property on the combobox. This specifies the field in the source data objects to use in the label.

<s:ComboBox dataProvider="{custArray}" labelField="name"/>

OTHER TIPS

The ComboBox has several ways to specify what it should use as the "label" for each item in the dataProvider:

  • By default, if the elements in the dataProvider has a property named label, and that property contains a String it will display that value.
  • ComboBox has a labelField property that you can use to tell it where to find the "label" for each item. In your case, you could set the labelField to "name"
  • ComboBox has a labelFunction property that allows you to use a function (that you write) to specify what text should be displayed for each item.

I suggest using the the labelField, as that seems the most straight forward in this case:

<s:ComboBox dataProvider="{custArray}" labelField="name" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top