I started some work on this feature.  I created a JIRA issue here: 
https://issues.apache.org/jira/browse/FLEX-35232

I created a simple implementation, FilteredArrayList, that is just a
subclass of ArrayList.

I created an IFilter interface to define the filter, rather than the
Function used by ArrayCollection.  I originally tried to use a Function, but
I found that it did not convert properly in the Javascript application.

This solution maintains a second ArrayList that represents the elements that
match the given filter.  The ArrayList functions are overridden to update
this list as appropriate.

I confirmed that I could use FilteredArrayList with a DataGrid.  See
TestFilteredArrayList.zip in JIRA for an example project.  Note that the
changes will not be updated to DataGrid until you click "Refresh"

Some notes:
- This is a proof of concept.  The class needs some more robustness and
testing before it is ready for "production"
- I used the filtered list for the {{getItemAt}} and {{length}}
implementation
- For other functions that use a specific index (addItemAt, removeItemAt,
updateItemAt), I used the index of the parent class.  This could be a bit
unintuitive for some cases
- I have not implemented getItemIndex, itemUpdated, itemUpdatedAt, and
setItemAt
- There is no way to read items directly from the underlying list, for now.
- I have not yet created a specialized interface for this class (i.e.
IFilteredArrayList).  I haven't seen an advantage to this, yet.
- I have not added any events to the functions.  


I have attached an example application as TestFilteredArrayList.zip to the
JIRA issue.  The FilteredArrayList implementation is in:
- src/collections/FilteredArrayList.as
- src/collections/IFilter.as

Joel Anderson
My Apache Flex community contribution is working on the open source
Moonshine-IDE.com for FlexJS. 




--
View this message in context: 
http://apache-flex-development.2333347.n4.nabble.com/Filter-function-to-ArrayList-tp57239p57642.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply via email to