I have a List, and I have an ArrayCollection.
The ArrayCollection is something like:
<mx:ArrayCollection id="arrColl">
<mx:source>
<mx:Array>
<mx:Object label="Student A" score="85,36,43,67,54,47" />
<mx:Object label="Student B" score="85,36,43,67,54,47" />
<mx:Object label="Student C" score="85,36,43,67,54,47" />
</mx:Array>
</mx:source>
</mx:ArrayCollection>
I need the List to only display the scores of the student.
Something like:
<s:开发者_如何学GoList dataprovider="arrColl[Student A]"/>
<s:List dataprovider="arrColl.Student A."/>
The problem is that the list control wont pick up this "34,65,36,87,12" variable and turn it into a IList List.
I figured it out, I first have to do this: studentAArray = new ArrayCollection(arrColl.score.split(",")); Then use studentAArray as the List dataprovider.
Don't do anything with the list to make this happen. You want to apply a filter to the ArrayCollection. The list will immediately pick up the filter, and remove invalid items from the view.
Set the dataProvider like this:
<s:List dataprovider="arrColl"/>
Then create a filterFunction, something like this:
public function StudentAFilter(item:Object):void{
if(item['label'] = "Student A"){
return true;
}
return false;
}
And somewhere in your code, do something like this:
arrColl.filterFunction = StudentAFilter;
arrColl.refresh()
The code above is often related to a button click or the change handler of a drop down list; depending how you want the user to filter the data.
精彩评论