For example, say I have:
public var usersOnlineArray:Array = new Array(bob,jim,tim,marry,luke);
and when I put that into my datagrid like this:
buddylist.dataProvider = new DataProvider(usersOnlineArray);
buddylist.rowCount = buddylist.length;
bldBuddyList(buddylist);
How could I, let’s say, prevent luke from appearing in the datagrid? Basically make him not appear but technically “still be there” so I can make him reappear later but?
I’d start by using ArrayCollection rather than Array since you can make use of data binding this way.
ArrayCollection also has a
filterFunctionproperty that will allow you to hide things but still keep them in the collection. The docs will expand on all of this but the gist is:Make the ArrayCollection, it just takes plain ole Array in the constructor.
public var usersArr:Array = [bob, jim, tim, marry, luke];public var usersAC:ArrayCollection = new ArrayCollection(usersArr);Set the AC to be the data provider for the List.
buddyList.dataProvider = usersAC;Define the filter function. This function takes an object and returns true if it should be visible, false if not.
Then apply this function to the AC.
usersAC.filterFunction = myFilterFunction;To remove the filter simply null our the filterFunction property.
usersAC.filterFunction = null;