It looks like there is more work going on here than necessary.  There should be 
no need to loop through the filteredArr and add and remove things.  You should 
be able to set the source or list property of the filteredAr to the source, 
toArray or list of archiveAr and maybe apply the same filter.  It depends a bit 
on what you want to share, if anything.

Anyway, regarding the filter function, since you already are filtering based on 
generalSearch.text, I don’t see why you can’t add other logic to further test 
on someOtherTextField.text.


On 3/5/13 8:56 PM, "ZIONIST" <stinas...@yahoo.com> wrote:






Alex, i have an arraycollection (archiveAr) which i would like to filter based 
on the following multiple parameters; Keywords, title and subject. i would like 
to use 3 textinputs to do this. one for keywords, another for title and the 
last one for subject. Now i can only use one textinput to filter based on 
keywords and would like to have all of them filter the array collection 
depending on the users choice. below is the code i have so far. someone please 
help.

/******************* code to get Archives *****************************/

 //[Bindable]

 private var archiveAr:ArrayCollection=new ArrayCollection();

 /* [Bindable]

 private var filteredAr:ArrayCollection = new

ArrayCollection(archiveAr.toArray()); */

 [Bindable]

 private var filteredAr:ArrayCollection=new ArrayCollection();

 private function archiveResult(event:ResultEvent):void

 {

 archiveAr=event.result as ArrayCollection;

 //filteredAr=event.result as ArrayCollection;

 }

 /******************* Start Filter Functions ***************************/

 private var keywordText:String="keywords";

 private function filterGrid():void

 {

 archiveAr.filterFunction=myFilterFunction;

 archiveAr.refresh();

 for (var i:int=archiveAr.length - 1; i >= 0; i--)

 {

 if (!filteredAr.contains(archiveAr[i]))

 {

 filteredAr.addItem(archiveAr[i]);

 }

 }

 for (i=filteredAr.length - 1; i >= 0; i--)

 {

 if (!archiveAr.contains(filteredAr[i]))

 {

 filteredAr.removeItemAt(i);

 }

 }

 }

 private function filterReset():void

 {

 archiveAr.filterFunction=null;

 archiveAr.refresh();

 }

 private function myFilterFunction(item:Object):Boolean

 {

 return item[keywordText].match(new RegExp(generalSearch.text, 'i'));

 //return item[keywordText].match(new RegExp("^"+generalSearch.text, 'i'));

 }

 private function keywordChangeHandler(event:Event):void

 {

 if (generalSearch.text != '')

 {

 filterGrid();

 }

 else

 {

 filterReset()

 }

 }






--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui

Reply via email to