Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default filterFunction woes

    Okay, I'm working on a filter function to sort through information in an
    ArrayCollection which is filled by the results of a select statement to
    a database. The actual functionaility is modified ever so slightly from
    the source I found here:

    [url]http://www.franto.com/blog2/wp-content/uploads/examples/filterfunction/s\[/url]
    rcview/

    This is what I have:
    ------------------------
    private function filterProducts():void
    {
    model.prodMaintData.filterFunction = sortProducts;
    model.prodMaintData.refresh();
    }

    private function sortProducts(item:Object):Boolean
    {
    var value:String;
    var col:String = this.cmbColumns.selectedItem.data as String;
    searchBy = this.txtDescription.text;

    searchBy = searchBy.toLowerCase();

    if (searchBy != "")
    {
    if (col != "any")
    {
    value = item[col]; //Why is value NOT getting set
    equal to this?
    value = value.toLowerCase(); //Error happens here
    because value is still null for some reason

    if (value.indexOf(searchBy) >= 0)
    {
    return true;
    }
    }
    else
    {
    for (var o:String in item)
    {
    value = item[o];
    value = value.toLowerCase();
    if (value.indexOf(searchBy) >= 0)
    {
    return true;
    }
    }
    }
    }
    else
    {
    return true;
    }

    return false;
    }
    ------------------------

    Now, as seen by my comments, I keep getting an error because the value
    variable is null for some reason, even when lines were changed around
    from what was originally from the sample. I don't know if this has
    anything to do with it, but despite the fact that my comboBox is
    populated by an ArrayCollection that was declared and filled manually in
    the code:

    ------------------------
    columnArray = new ArrayCollection();
    columnArray.addItem({data:'any', label:'Any'});
    columnArray.addItem({data:'productID', label:'Product ID'});
    columnArray.addItem({data:'productName', label:'Product
    Name'});
    columnArray.addItem({data:'print', label:'Print'});
    columnArray.addItem({data:'barcode', label:'Barcode'});
    columnArray.addItem({data:'vendor', label:'Vendor'});
    columnArray.addItem({data:'status', label:'Status'});
    ------------------------

    The ArrayCollection which populates the dataGrid, the one I'm trying to
    sort through, is instantiated and populated automatically again from a
    database table. I don't see the reason why the value variable should be
    null and causing the error. Thanks in advance.

    Brian Ross Edwards

    bre358 Guest

  2. Similar Questions and Discussions

    1. Filtering a datagrid without using filterFunction?
      Hello, I'm looking for a way to filter a datagrid without applying a filterFunction on the arrayCollection. The filter is static. I need it to...
    2. XMLListCollection and filterFunction
      I'm trying to do the same thing. Have you figured anything out yet? filterFunction seems to have a major flaw in that it only works for the root...
    3. filterFunction on multiple levels
      I am using filterFunction on a XMLListCollection to filter data. It works fine except it only filters the first level of data. Is there someway to...
    4. WSE 2 woes
      I have created the Hello World web service and implemented WSE 2 tokens to validate against a database. I am using VS 2003 and installed the...
    5. PDF woes
      EPS files are intended to be placed on a page in a page-layout program, and thus contain no page orientation or page size information. If you are...
  3. #2

    Default Re: filterFunction woes

    Have you verified that all values of "col" encountered are indeed properties of "item"?
    Tracy
    ntsiii Guest

  4. #3

    Default Re: filterFunction woes

    Also, please use the "attach Code" button to display code. It is too hard to read otherwise.

    Tracy
    ntsiii Guest

  5. #4

    Default Re: filterFunction woes

    Noted and noted, turns out that the value attached to 'col' was not matching
    what was in item. All I needed to do was edit the data values in the Array that
    was populating the column combo box and everything works like a charm. Thanks
    anyway, sometimes a mundane detail needs to be pointed out to be seen. Sorry
    about not using the "attach code feature", it vanished from the AIR forums and
    I forget it still exists here.

    bre358 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139