separating data in an array for display in Flex

2019-08-27 01:03发布

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 !!!

2条回答
成全新的幸福
2楼-- · 2019-08-27 01:40

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"/>
查看更多
老娘就宠你
3楼-- · 2019-08-27 01:48

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" />
查看更多
登录 后发表回答