separating data in an array for display in Flex

不问归期 提交于 2020-01-06 08:48:09

问题


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


回答1:


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"/>



回答2:


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" />


来源:https://stackoverflow.com/questions/16986018/separating-data-in-an-array-for-display-in-flex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!