Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Datagrid filtering component. Where should the filtering code go?  (Read 4382 times)
jgervin
Courseware Beta
Sr. Member
***
Posts: 50


View Profile Email
« 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?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
jgervin
Courseware Beta
Sr. Member
***
Posts: 50


View Profile Email
« Reply #2 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?

Logged
jgervin
Courseware Beta
Sr. Member
***
Posts: 50


View Profile Email
« Reply #3 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.
« Last Edit: April 06, 2011, 01:24:40 by jgervin » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 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>
Logged
Pages: [1]
Print