0 Replies Latest reply on Aug 23, 2006 9:06 AM by GeorgeWS

    Filtering

    GeorgeWS Level 1
      I have this code below and the InputText filter part works to filter the grid. I also have a drop down box that I want to choose what column the InputText should filter. The drop down part does not do anything at this time. There is a a column header named PDES5W that I have hard coded into the filter. How can I have the drop down change this?

      you can see it work here: http://www.youngsmarket.com/youngsmarket/programs/inventory/inventory/bin/Inventory.html

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp()" >

      <mx:Script>
      <![CDATA[
      import mx.rpc.events.ResultEvent;
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;

      [Bindable]
      public var myData:ArrayCollection;

      [Bindable]
      public var aReturnTypes: Array = [ {label:"query", data:"query"} ];

      [Bindable]
      public var returnType:String="string";

      public function clearAll():void{

      myData=new ArrayCollection();
      }

      public function handleQueryResult(event:ResultEvent):void{
      myData=event.result as ArrayCollection;
      myData.filterFunction=processFilter;
      }

      public function processFilter(item:Object):Boolean
      {
      var result:Boolean=false;
      var pattern:RegExp= new RegExp("^"+txtFilter.text,"i");
      if (!item.PDES5W.length
      || item.PDES5W.match(pattern))
      result=true;

      return result;
      }

      [Bindable]
      public var myfilter: Array = [ {label:"Description", data:"PDES5W"},
      {label:"Product ID", data:"PNUM5W"}, {label:"Size", data:"SDIVDE"}, {label:"Pack", data:"ISCF3W"}, {label:"Rank", data:"DIVN5W"} ];

      [Bindable]
      public var selectedItem:Object;

      [Bindable]
      private var downloadLabel:String;

      private function initApp() : void {
      downloadLabel = Application.application.parameters.name;
      }

      private function gotoURL() : void {
      var url:URLRequest = new URLRequest(" http://www.youngsmarket.com/youngsmarket/programs/inventory/Inventory.cfm?name="+Applicati on.application.parameters.name);
      navigateToURL(url);
      }
      ]]>
      </mx:Script>

      <mx:RemoteObject
      id="qResult"
      destination="ColdFusion"
      source="Inventory"
      showBusyCursor="true"
      >

      <mx:method name="Inventory" result="handleQueryResult(event)" fault="Alert.show(event.fault.message)"/>

      </mx:RemoteObject>

      <mx:Panel title="Inventory" height="90%" width="100%"
      paddingTop="5" paddingLeft="5" paddingRight="5" paddingBottom="5" cornerRadius="10" roundedBottomCorners="true">


      <mx:HBox width="100%">
      <mx:Label text="Filter:"/>
      <mx:TextInput width="100" id="txtFilter" change="myData.refresh()" />
      <mx:ComboBox id="columnfilter" dataProvider="{myfilter}" width="125"
      close="selectedItem=ComboBox(event.target).selectedItem"/>
      <mx:RadioButton label="Warehouse" click="accordion.selectedIndex=0;" selected="true"/>
      <mx:RadioButton label="Cash / Carry" click="accordion.selectedIndex=1;"/>
      <mx:RadioButton label="Storage" click="accordion.selectedIndex=2;"/>
      <mx:Spacer width="100%" height="20"/>
      <mx:LinkButton label="Download{downloadLabel}" click="gotoURL()" />
      </mx:HBox>

      <mx:Accordion id="accordion" width="100%" height="100%" headerHeight="5">
      <mx:VBox height="100%" >
      <mx:DataGrid dataProvider="{myData}" initialize="qResult.Inventory()" width="100%" height="100%">
      <mx:columns>

      <mx:DataGridColumn dataField="PNUM5W" headerText="Prod ID" width="55"/>
      <mx:DataGridColumn dataField="PDES5W" headerText="Desc" width="163"/>
      <mx:DataGridColumn dataField="SDIVDE" headerText="Size" width="50"/>
      <mx:DataGridColumn dataField="ISCF3W" headerText="Pac" width="35"/>
      <mx:DataGridColumn dataField="DIVN5W" headerText="Rnk" width="35"/>

      <mx:DataGridColumn dataField="INV_11" headerText="Or Inv" width="50"/>
      <mx:DataGridColumn dataField="ORD_11" headerText="Or Ord" width="50"/>
      <mx:DataGridColumn dataField="DAT_11" headerText="Or Due" width="50"/>
      <mx:DataGridColumn dataField="INT_11" headerText="Or InT" width="50"/>

      <mx:DataGridColumn dataField="INV_31" headerText="Ch Inv" width="50"/>
      <mx:DataGridColumn dataField="ORD_31" headerText="Ch Ord" width="50"/>
      <mx:DataGridColumn dataField="DAT_31" headerText="Ch Due" width="50"/>
      <mx:DataGridColumn dataField="INT_31" headerText="Ch InT" width="50"/>

      <mx:DataGridColumn dataField="INV_41" headerText="MH Inv" width="50"/>
      <mx:DataGridColumn dataField="ORD_41" headerText="MH Ord" width="50"/>
      <mx:DataGridColumn dataField="DAT_41" headerText="MH Due" width="50"/>
      <mx:DataGridColumn dataField="INT_41" headerText="MH InT" width="50"/>

      </mx:columns>
      </mx:DataGrid>
      </mx:VBox>

      <mx:VBox height="100%" >

      </mx:VBox>
      </mx:Accordion>
      </mx:Panel>
      </mx:Application>