2 Replies Latest reply on Jun 10, 2008 1:05 PM by EvolvedDSM

    Help, filtering DG using text box and combobox

    EvolvedDSM Level 2
      I've got a populated DG from an arrayCollection. I have a text input where I can type in my search criteria to filter the DG. I also have a combo box that contains a list of all the columns of my DG, so I can determine which column to apply the filter on.

      I've been able to do a text filter on a DG in the past if I use a static data name from my arraycollection, but this time I want it to be dynamic using the combo box.
      Here's an example of my setup:
      The DG contains columns A, B, C, D, and E. The combo box contains the choices A, B, C, D, and E -- which the label and the data value are the same in this case. If I select choice D from the combo box and begin typing into my text input, the DG should begin to filter according to my input against the values of column D.

      Here's my working code for statically filtering the D column:
      private function filterColumn():void{
      sFilter = TextFilter.text;
      myAC.filterFunction = doFilter;
      myAC.refresh();
      }
      private function doFilter(obj:Object):Boolean{
      var result:Boolean=false;
      if (!obj.D.length || obj.D.toUpperCase().indexOf(sFilter.toUpperCase()) >= 0){
      result=true;
      }
      return result;
      }

      This code will allow me to type into the text input and it will filter only the D column. The value of the combo box does not matter at this point.

      What I need the code to do is use the combobox.selectedItem.data value in place of D. However when I try this, it tells me -- TypeError: Error #1123: Filter operator not supported on type Object

      Using most of the above code, I just changed the IF statement to:
      if (!obj.(cbx.selectedItem.data).length || obj.(cbx.selectedItem.data).toUpperCase().indexOf(sFilter.toUpperCase()) >= 0)
      And that produces the above error.

      Can anyone help me figure out how to substitute a static column value for the dynamic combobox value? Any help is appreciated.