PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: jgervin on April 06, 2011, 07:08:45



Title: Datagrid filtering component. Where should the filtering code go?
Post by: jgervin on April 06, 2011, 07:08:45
We have a PureMVC based app and we are creating a filtering component, like Apples Finder filter, and I am wondering where to put the filtering code?  I first put filtering function in the mediator, but when we decided to make the component a reusable component that breaks down as now we have duplicate filtering code in several mediators.

Has anyone done this or does anyone have any suggestions?


Title: Re: Datagrid filtering component. Where should the filtering code go?
Post by: puremvc on April 06, 2011, 07:15:45
I would consider that encapsulated behavior of the component (i.e. the filter should probably go in the component itself).

-=Cliff>


Title: Re: Datagrid filtering component. Where should the filtering code go?
Post by: jgervin on April 06, 2011, 07:27:59
Do you think having the component clone or copy the dataProvider filtering it then dispatching an event the mediator listen for then have the mediator assign the cloned filtered data (arrayCollection) as the new dataProvider?  Keeping a backup of the original in the mediator of course?



Title: Re: Datagrid filtering component. Where should the filtering code go?
Post by: jgervin on April 06, 2011, 01:20:49
Does this still hold true if the component is just the filter control container?  Meaning the filter component does not contain the datagrid, but visually sits above it.  The reason for this is the filter might be used with s:List, mx:datagrid, etc....

So I am thinking in the filterComp I would give it reference via a property some dataProvider of external s:List or mx:Datagrid (ArrayCollection) then when run assign a filter to that DP.


Title: Re: Datagrid filtering component. Where should the filtering code go?
Post by: puremvc on April 06, 2011, 02:28:25
1) Mediate the FilterComp,
2) Push the collection into it via a public implicit getter/setter pair.
3) In the setter, add the filter to the collection and do a refresh.
4) In the component that contains both the DataGrid and the FilterComp instance, bind the dataprovider property of the DataGrid to the collection 'property' (represented by the implicit accessors) of the FilterComp.

-=Cliff>