I'm also trying something similar, but with various components:

http://s256908546.onlinehome.us/datagrid/am_post.html

I can't get the filtering to work correctly.


--- In [email protected], "alinmircea_s" <alinmirce...@...> wrote:
>
> From what I understand, is this what you're looking for? (a quick
> example for you get the basic idea. There are better and cleaner ways
> to do this.)
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="vertical">
> 
> 
> <mx:Script>
> <![CDATA[
> import mx.collections.ICollectionView;
> private function filterScChange(event:Event):void
> {
> ICollectionView(grid.dataProvider).filterFunction = filter;
> ICollectionView(grid.dataProvider).refresh();
> }
> public function filter(item:Object):Boolean
> {
> if (item.test1.toUpperCase().match(f1.selectedLabel.toUpperCase()) ||
> item.test2.toUpperCase().match(f2.selectedLabel.toUpperCase()) ||
> item.test3.toUpperCase().match(f3.selectedLabel.toUpperCase()) ||
> item.test4.toUpperCase().match(f4.selectedLabel.toUpperCase()))
> return true;
> return false;
> }
> ]]>
> </mx:Script>
> 
> 
> <mx:ComboBox id="f1" labelField="test1" dataProvider="{datap1}"
> change="filterScChange(event)"/>
> <mx:ComboBox id="f2" labelField="test2" dataProvider="{datap1}"
> change="filterScChange(event)"/>
> <mx:ComboBox id="f3" labelField="test3" dataProvider="{datap1}"
> change="filterScChange(event)"/>
> <mx:ComboBox id="f4" labelField="test4" dataProvider="{datap1}"
> change="filterScChange(event)"/>
>       
> 
> 
> <mx:ArrayCollection id="datap">
> <mx:Object test1="some" test2="random" test3="text" test4="here"/>
> <mx:Object test1="also" test2="here" test3="and" test4="here"/>
> <mx:Object test1="here" test2="and" test3="here" test4="also"/>
> <mx:Object test1="here" test2="some" test3="random" test4="text"/>
> </mx:ArrayCollection>
> 
> <mx:ArrayCollection id="datap1">
> <mx:Object test1="some" test2="random" test3="text" test4="here"/>
> <mx:Object test1="also" test2="here" test3="and" test4="here"/>
> <mx:Object test1="here" test2="and" test3="here" test4="also"/>
> <mx:Object test1="here" test2="some" test3="random" test4="text"/>
> </mx:ArrayCollection>
> 
> 
> <mx:DataGrid id="grid" dataProvider="{datap}">
> <mx:columns>
> <mx:DataGridColumn headerText="UserId" dataField="test1"/>
> <mx:DataGridColumn headerText="UserName" dataField="test2"/>
> <mx:DataGridColumn headerText="Active" dataField="test3"/>
> <mx:DataGridColumn headerText="Last seen" dataField="test4"/>
> </mx:columns>
> </mx:DataGrid>
> </mx:Application>
>


Reply via email to