Filter and refresh function for ArrayCollection : ArrayCollection « Data Model « Flex






Filter and refresh function for ArrayCollection

Filter and refresh function for ArrayCollection
            
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    backgroundColor="white">
    <mx:Script>
        
        import mx.collections.ArrayCollection;
        [Bindable]
        public var salesAC:ArrayCollection = new ArrayCollection([
            {name:"A",value:1},
            {name:"B",value:2},
            {name:"C",value:3},
            {name:"D",value:4},
            {name:"E",value:5},
            {name:"F",value:6}
        ]);
        public function filterFunc(item:Object):Boolean
        {
            if(item.value >= salesRange.values[0] && item.value <=  salesRange.values[1])
                return true;
            else
                return false;
        }
        public function filterSales():void
        {
            salesAC.filterFunction=filterFunc;
            salesAC.refresh();
        }
      
    </mx:Script>
    <mx:Panel width="400" height="300" title="Sales Dashboard">
        <mx:HSlider change="filterSales()"
                    id="salesRange"
                    width="100%"
                    thumbCount="2"
                    labels="['0','2','5','7','10']"
                    tickInterval="1" 
                    height="50" 
                    maximum="10"/>
        <mx:DataGrid id="dg" width="100%" height="100%" dataProvider="{salesAC}">
            <mx:columns>
                <mx:DataGridColumn headerText="Country" dataField="name" />
                <mx:DataGridColumn headerText="Revenue" dataField="value" />
            </mx:columns>
        </mx:DataGrid>
    </mx:Panel>
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Add element to ArrayCollection and bind to DataGridAdd element to ArrayCollection and bind to DataGrid
2.Define Array object and use it as source for ArrayCollectionDefine Array object and use it as source for ArrayCollection
3.Using an array of components to dispaly ButtonsUsing an array of components to dispaly Buttons
4.Initializing an ArrayCollection using MXML with embedded data
5.ArrayCollection is initialized with ActionScript
6.Using an ArrayCollection to feed the DataGrid's dataProviderUsing an ArrayCollection to feed the DataGrid's dataProvider
7.Using nested data in an ArrayCollection to display hierarchicallyUsing nested data in an ArrayCollection to display hierarchically
8.ArrayCollection data providerArrayCollection data provider
9.Use ActionScript to declare and create the ArrayCollection objectUse ActionScript to declare and create the ArrayCollection object
10.Insertion on the Array and ArrayCollectionInsertion on the Array and ArrayCollection
11.Sort ArrayCollectionSort ArrayCollection
12.Add item to ArrayCollectionAdd item to ArrayCollection
13.Remove item from ArrayCollection by indexRemove item from ArrayCollection by index
14.Update item in ArrayCollectionUpdate item in ArrayCollection
15.ArrayCollection collectionChange eventArrayCollection collectionChange event
16.Create ArrayCollection from ArrayCreate ArrayCollection from Array
17.Use Timer to add data to ArrayCollectionUse Timer to add data to ArrayCollection
18.Put random value to ArrayCollectionPut random value to ArrayCollection
19.Bind ArrayCollection to List and update ArrayCollection to change ListBind ArrayCollection to List and update ArrayCollection to change List
20.Use individual ArrayCollection elements as the source or a binding expressionUse individual ArrayCollection elements as the source or a binding expression
21.Get data from ArrayCollection by label fieldGet data from ArrayCollection by label field
22.Use Model as the source for ArrayCollection
23.Create ArrayCollection from Model with ActionScriptCreate ArrayCollection from Model with ActionScript
24.Get data frolm ArrayCollection by using index and property nameGet data frolm ArrayCollection by using index and property name
25.Using ArrayCollection to handle complex dataUsing ArrayCollection to handle complex data
26.Converting an MXML data model into an ArrayCollectionConverting an MXML data model into an ArrayCollection
27.Simple ArrayCollection
28.Add filter to ArrayCollectionAdd filter to ArrayCollection
29.Spark DropDownList with Static String ArrayCollectionSpark DropDownList with Static String ArrayCollection
30.An ArrayCollection object that is populated from a remote data sourceAn ArrayCollection object that is populated from a remote data source
31.Define ArrayCollection Of ObjectsDefine ArrayCollection Of Objects
32.Create an Array, and then converts it to an ArrayCollectionCreate an Array, and then converts it to an ArrayCollection
33.Use an tag to perform the conversionUse an <s:ArrayCollection> tag to perform the conversion
34.Real Time ArrayCollectionReal Time ArrayCollection
35.defines data providers as ArrayCollections.defines data providers as ArrayCollections.
36.Use ArrayCollection to store controlsUse ArrayCollection to store controls
37.A sorted view of a collectionA sorted view of a collection
38.Set item at third position to new valueSet item at third position to new value
39.Result of using insert() and remove() on the current propertyResult of using insert() and remove() on the current property