![]() |
![]() |
||||||
|
|||||||
| Tags: arraycollection, extract, subset |
![]() |
|
|||
|
Is there a way to extract a subset of an array collection where a particular
value is found, without doing it manually EG { {t=4,s=3} { t=3,s=3} { t=3,s=3} } Extract where t = 3 returns { { t=3,s=3} { t=3,s=3} } |
| Sponsored Links |
|
|||
|
"nikos101" <webforumsuser@macromedia.com> wrote in message news:g95kq6$31b$1@forums.macromedia.com... > Is there a way to extract a subset of an array collection where a > particular > value is found, without doing it manually > > EG { > {t=4,s=3} > { t=3,s=3} > { t=3,s=3} > } > > Extract where t = 3 > > returns > > { > { t=3,s=3} > { t=3,s=3} > } filterFunction |
|
|||
|
Well, if you set a filterFunction, you'd need to iterate through the
ArrayCollection to get the filtered version. Each iteration will cause an execute to filterFunction. You're better off manually iterating through the array. Though, if you want the filtering to happen when you have a view attached to your ArrayCollection like a datagrid or a list, then a filterFunction is the best solution. |
|
|||
|
"anirudhs" <webforumsuser@macromedia.com> wrote in message news:g96b39$qtu$1@forums.macromedia.com... > Well, if you set a filterFunction, you'd need to iterate through the > ArrayCollection to get the filtered version. Each iteration will cause an > execute to filterFunction. No, you just call yourAC.refresh() after applying the filter. Then any references to yourAC will only show the filtered data. HTH; Amy |
|
|||
|
Exactly. yourAC.refresh() is what calls the filterFunction for each element in
the array: This is from mx.collections.ListCollectionView: if (filterFunction != null) { var tmp:Array = []; var len:int = localIndex.length; for (var i:int = 0; i < len; i++) { var item:Object = localIndex[i]; if (filterFunction(item)) { tmp.push(item); } } localIndex = tmp; } This is the code that gets executed when you set a filterFunction and call refresh. This "iteration" is what I was referring to in my previous post. Sorry if it wasn't very clear. You generally do not want to do so much if all you want is a subset from the array collection without the arraycollection being mapped to a view or something. HTH, Anirudh Sasikumar |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise