Hi,

I have tried it but facing a problem when I try to access 
DataCollection from another MXML testCombo.mxml. 

Please Suggest:::

See the following Code:

filterTest.mxml::::

<?xml version="1.0" ?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";  
xmlns="../*"  >

<mx:Script>
<![CDATA[
                import mx.collections.ArrayCollection;
                import mx.core.ClassFactory;

public var object2:Object = new Object();
public var object:Object = new Object();
[Bindable]
        
         
         [Bindable]
       public var authorsDataProvider : ArrayCollection = new 
ArrayCollection( [
            { Country: "USA", Gold: 35, Status:"Active", 
URL:"http://www.google.com"; },
            { Country: "China", Gold: 32, 
Status:"Deactive",URL:"http://www.yahoo.com"},
            { Country: "Russia", Gold: 27,Status:"Deactive", 
URL:"http://www.hotmail.com"; },
            { Country: "India", Gold: 12, 
Status:"Active",URL:"http://www.gmail.com"},
            {Country: "Russia", Gold: 27, 
Status:"Deleted",URL:"http://www.hotmail.com"; },
            {Country: "Russia", Gold: 27, 
Status:"Deleted",URL:"http://www.hotmail.com"; } ]);

]]>
</mx:Script>
<mx:Panel title="Header Filter" width="100%" height="100%">
      <mx:DataGrid id="grid" dataProvider="{authorsDataProvider}" 
width="100%" height="100%" sortableColumns="false"   >
        <mx:columns>
          <mx:Array>
            <mx:DataGridColumn width="300" headerText="Country" 
dataField="Country" />
            <mx:DataGridColumn width="300" headerText="Value" 
dataField="Gold"/>
            <mx:DataGridColumn width="300" headerText="Status" 
dataField="Status" headerRenderer="testCombo"/>
            <mx:DataGridColumn width="300" headerText="URL" 
dataField="URL"/>
          </mx:Array>
        </mx:columns>
      </mx:DataGrid>
    </mx:Panel>
</mx:Application>



testCombo.mxml:::::


<?xml version="1.0" encoding="utf-8"?>

<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml";>
    <mx:Label text="Sale Price!"/>
    <mx:ComboBox id="cboAuthorsStatusFilter"
    dataProvider="{authorsStatusArray}" 
    change="filterAuthorsGrid();"
    >
    
    
    <!-- dataProvider="{_parent._parent.gridData}">-->
        <mx:Script>
                <![CDATA[
                        import mx.controls.Alert;
                        import mx.collections.*;
                        [Bindable]  
                        public var authorsArray:Array = ["All",
                        "Active",
                        "Deactive",
                        "Deleted"];
                        
                         [Bindable] 
                        public var authorsStatusArray : Array = 
populateAuthorsStatusArray(authorsArray);

                        public function populateAuthorsStatusArray
(authorsArray:Array):Array
                        {
                                //Alert.show
("authorsArray: "+authorsArray.toString())
                                var statusArrayHashMap : Object = 
new Object();   
                                var statusArray : Array = new Array; 
                                var n:int = authorsArray.length; 
                                for (var i:int = 0; i < n; 
i++)             
                                {                    
                                        if (statusArrayHashMap
[authorsArray] == undefined)                    
                                
        {                               
                                                statusArrayHashMap
[authorsArray] = new Object();                               
                                                statusArray.push
(authorsArray[i]);                    
                                        } else
                                        {
                                                statusArray.push
(authorsArray [i]);  
                                        }
                                                   
                                }             
                                return statusArray;
                        } 
                        public function filterAuthorsGrid():void
                        {
                                Alert.show(this.toString() 
+" : "+authorsDataProvider)
                        
        //authorsDataProvider.filterFunction=authorsStatusFilter;    
           
                                //authorsDataProvider.refresh();
                        }
                        public function authorsStatusFilter
(item:Object):Boolean       
                        {               
                                if 
(cboAuthorsStatusFilter.selectedItem != "All")               
                                {                       
                                        return item.status == 
cboAuthorsStatusFilter.selectedItem; 
                                } else {
                                        return true;               
                                } 
                                //return true;     
                        }
                        

                    ]]>
        </mx:Script>
</mx:ComboBox>

</mx:HBox>


--- In [email protected], "sanjaypmg" <[EMAIL PROTECTED]> wrote:
>
> Thanks Phil,
> .... :) That's what I was looking for...Now I'll try to convert it 
> into Flex2.0.
> 
> Wish me luck.... ;)
> 
> Thanks,
> Sanjay
> 
> --- In [email protected], "phipzkillah" <pkrasko@> wrote:
> >
> > I am also looking for this functionality.  About a month ago I 
came
> > across this page
> > <http://www.cflex.net/showFileDetails.cfm?
> ObjectID=299&Object=File&Chann\
> > elID=1> .  It is a sample of a datagrid whose headers have a 
drop 
> down
> > list to filter each field/column on.  Unfortuneately it was 
> developed in
> > Flex 1.5.  Has anyone converted it to Flex 2.0?  If so, this is 
the
> > answer we all are looking for.
> > 
> > If someone can copy that source code and eliminate the compiler 
> errors
> > you will be doing several of us a huge favor!
> > 
> > Thanks
> > 
> > Phil
> > 
> > --- In [email protected], "sanjaypmg" <sanjaypmg@> 
wrote:
> > >
> > > Hi There,
> > >
> > > Is there any way to put filters feature on Datagrid as 
available 
> in
> > > Excel?
> > >
> > > Or
> > >
> > > Anything Similar to that feature?
> > >
> > > Please let me know if there is something or any possible 
> solution for
> > > the same.
> > >
> > > Thanks
> > > Sanjay sharma
> > >
> >
>


Reply via email to