2 Replies Latest reply on Mar 12, 2008 4:54 PM by Peter deHaan

    filtering a datagrid with a checkbox

    GeorgeWS Level 1
      I have a Datagrid and a check box. I want to check the checkbox and the data that is in CASTSDTY column that is equal to 0.00 to be left. I have this but get an error.

      public function processFilter(item:Object):Boolean
      var result:Boolean=false;
      if((hitList.selected == true || item.CASTSDTY == "0.00"))
      return result;

      <mx:CheckBox id="hitList" click="natactivListAC.refresh()" label="Hit List" selected="false" width="96" themeColor="#73B9B9"/>

      <mx:DataGrid id="mainList" dataProvider="{natactivListAC}" itemClick="itemClicked(event)" width="100%" height="100%" paddingBottom="5" paddingRight="5" themeColor="#73B9B9">
      <mx:DataGridColumn headerText="Customer" width="65" dataField="CUSN05"/>
      <mx:DataGridColumn headerText="Loc" width="35" dataField="DSEQ05"/>
      <mx:DataGridColumn headerText="DBA" minWidth="100" dataField="CAD105"/>
      <mx:DataGridColumn headerText="Item ID" width="60" dataField="ItemID"/>
      <mx:DataGridColumn headerText="Item" minWidth="75" dataField="Item"/>
      <mx:DataGridColumn headerText="Cs TY" minWidth="20" dataField="CASTSDTY" textAlign="right"/>
      <mx:DataGridColumn headerText="Cs LY" minWidth="20" dataField="CASTSDLY" textAlign="right"/>
      <mx:DataGridColumn headerText="Dol TY" minWidth="20" dataField="LVALSDTY" textAlign="right"/>
      <mx:DataGridColumn headerText="Dol LY" minWidth="20" dataField="LVALSDLY" textAlign="right"/>
      <mx:DataGridColumn headerText="Goal" minWidth="20" dataField="Goal" textAlign="right"/>

      Any thoughts?

        • 1. Re: filtering a datagrid with a checkbox
          GeorgeWS Level 1
          Anyone? I tried different stuff all day. Any samples I dont know about?
          • 2. Re: filtering a datagrid with a checkbox
            Peter deHaan Level 4
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"

            import mx.controls.dataGridClasses.DataGridColumn;

            private function toggleFilter():void {
            if (checkBox.selected) {
            arrColl.filterFunction = processFilter;
            } else {
            arrColl.filterFunction = null;

            private function processFilter(item:Object):Boolean {
            return (Number(parseFloat(item.value)) == 0);

            private function value_labelFunc(item:Object, col:DataGridColumn):String {
            return item[col.dataField].toFixed(2);

            <mx:ArrayCollection id="arrColl">
            <mx:Object name="ColdFusion" value="0.00" />
            <mx:Object name="Dreamweaver" value="0.12" />
            <mx:Object name="Fireworks" value="1.01" />
            <mx:Object name="Flash" value="0" />
            <mx:Object name="Flash Player" value="-0.00" />
            <mx:Object name="Flex" value="0.00" />
            <mx:Object name="Illustrator" value="2.92" />
            <mx:Object name="Lightroom" value="0.32" />
            <mx:Object name="Photoshop" value="0.06" />

            <mx:CheckBox id="checkBox"
            click="toggleFilter();" />

            <mx:DataGrid id="dataGrid"
            <mx:DataGridColumn dataField="name" />
            <mx:DataGridColumn dataField="value"
            labelFunction="value_labelFunc" />