We help IT Professionals succeed at work.

custom Flex DataGrid Filter

Hi Experts,

I need to apply filter on custom Flex DataGrid using checkbox control which uses array collection filter Function. I have applied the logic on default DataGrid and it is working fine.
custom DataGrid has additional features in filtering. I need to add  more options because I have requirements to use  checkbox control with counter.

I have exported the project for you to look on to the source code and you will notice that only second DataGrid (Default) filtered based on the check box. I need to apply the same on the first DataGrid (Custom)  Your quick response is highly  appreciated.

The project source code can be loaded from this link

http://www.easy-share.com/1910961618/CustomDataGridFiter.zip



Thanks,
Comment
Watch Question

If you save your data in an ArrayCollection, then this contains a "filterfunction" property.
calling refresh() on the array collection lets it re-apply the filter. In this function you can add as many constraints as you like. Here some sample code.
                environmentData = ArrayCollection(event.result);
                environmentData.filterFunction = filterEnvironments;
                environmentData.refresh();

...

        private function filterChanged(item:Object):Boolean {
            environmentData.refresh();
        }

...

        private function filterEnvironments(item:Object):Boolean {
            var env:Handle = Handle(item);
            if (RegExpHelper.matches(_environmentFilter, env.title.toLocaleLowerCase())) {
                return true;
            }
            return (RegExpHelper.matches(_environmentFilter, env.toolTip.toLocaleLowerCase()));
        }        

Open in new window

Author

Commented:
ChristoferDutz:

I have no issues with default DataGrid. It gets filtered. I want to apply that concept on custom DataGrid in addition to its filtering features and if you run the application you will notice that.

Please advice.

Regards,

Author

Commented:
Please I need flex solution related.

FYI,
my problem is already explained and the project has been exported under this link.
You can download the project and have look on it to help you resolve the issue as soon as possible.

http://www.easy-share.com/1910961618/CustomDataGridFiter.zip

Your quick response to solve the problem is highly appreciated.
Commented:
By default MDatagrid doesnot allow you to modify the dataprovider.

http://www.iwobanas.com/2009/06/datagrid-with-client-side-filtering-and-searching/

"By default MDataGrid is using a local copy of data provider and doesn’t support removing/modifying items.
You can try setting copyDataProvider=false so that data provider will not be copied but I can’t guarantee that this will support deleting items."


So I changed your code of MDatagrid with copyDataProvider=false. Its working for me. But drawback will be that component won't have copy of database and filters added will be directly affecting the dataprovider.
<controls:MDataGrid dataProvider="{myData}" copyDataProvider="false"
							width="100%"
							height="100%">

Open in new window

Author

Commented:
Thanks vindys,

I think the proposed solution is acceptable as long we are using MDatagrid for search & display only. We can use default DataGrid to handle removing/modifying items.

Regards,