Are you sure you want to use && and not ||?

On 3/7/13 4:18 AM, "ZIONIST" <stinas...@yahoo.com> wrote:






hi when i try to apply the second search parameter, nothing gets filtered. here 
is my code. please advise.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical"
creationComplete="init()">

<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import mx.managers.CursorManager;
import mx.collections.ArrayCollection;

private function init():void
{

archiveSvc.getDocs();

}

/******************* code to get Archives *****************************/
[Bindable]
private var archiveAr:ArrayCollection=new ArrayCollection();

private function archiveResult(event:ResultEvent):void
{

archiveAr=event.result as ArrayCollection;

}

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

private var keywordText:String="keywords";
private var titleText:String="title";
private var subjectText:String="subject";

private function filterGrid():void
{

archiveAr.filterFunction=myFilterFunction;
archiveAr.refresh();

}

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'))) && 
(item[titleText].match(new RegExp(titleSearch.text, 'i')));

}

private function keywordChangeHandler(event:Event):void
{

if (generalSearch.text != '')
{
filterGrid();
}
else
{
filterReset()
}

}

private function titleChangeHandler(event:Event):void
{

if (titleSearch.text != '')
{
filterGrid();
}
else
{
filterReset()
}

}

]]>
</mx:Script>

<mx:RemoteObject id="archiveSvc"
 destination="ColdFusion"
 source="tilelistFilter.src.cfcs.crud"
 showBusyCursor="true"
 fault="CursorManager.removeBusyCursor();Alert.show(event.fault.message)">

<mx:method name="getDocs"
   result="archiveResult(event)"/>

</mx:RemoteObject>

<mx:HBox>

<mx:VBox horizontalAlign="center">
<mx:Label text="Keyword Search:"/>
<mx:TextInput id="generalSearch"
  change="keywordChangeHandler(event)"/>
</mx:VBox>

<mx:VBox horizontalAlign="center">
<mx:Label text="Search By Title:"/>
<mx:TextInput id="titleSearch"/>
</mx:VBox>

<mx:VBox horizontalAlign="center">
<mx:Label text="Search By Subject:"/>
<mx:TextInput id="subjectSearch"/>
</mx:VBox>

</mx:HBox>

<mx:TileList width="800"
 height="100%"
 dataProvider="{archiveAr}"
 itemRenderer="renderers.archiveRenders"/>

</mx:Application>






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

Reply via email to