Thursday, February 9, 2012

MS Excel Type Filter in Flex 4

I implemented MS-Excel kind of flitering long time back. The post can be found at this post:

The main method for that was the following filter function.


public function commonFilter(item:Object):Boolean{
02      var deviceFilterSelected:Boolean = (deviceColumn.selectedItem != null && deviceColumn.selectedItem != "All")?true:false;
03       var severityFilterSelected:Boolean = (severityColumn.selectedItem !=null && severityColumn.selectedItem != "All")?true:false;
04       var stupidityFilterSelected:Boolean = (stupidityColumn.selectedItem !=null && stupidityColumn.selectedItem != "All")?true:false;
05                
06                
07                if(deviceFilterSelected){
08                    if(item.device != deviceColumn.selectedItem)
09                        return false;
10                }
11                
12                if(severityFilterSelected){
13                    if(item.severity != severityColumn.selectedItem)
14                        return false;
15                }
16                
17                if(stupidityFilterSelected){
18                    if(item.stupidity != stupidityColumn.selectedItem)
19                        return false;
20                }
21                    /*Now return true*/
22                return true;
23            }
24 
25 
26 


I hope you will find it useful.

3 comments:

Anonymous said...

good post. I think we can also try to extend datagrid and add this functionality.

Anonymous said...

Hi, is there a project/ZIP file I can download? Thanks.

Akhil Mittal said...

You can find the code here :

http://cookbooks.adobe.com/post_MS_Excel_type_filtering_on_columns_of_datagrid_-17424.html

Thanks,
Akhil Mittal