Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
bre358 #1
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
-
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... -
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... -
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... -
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... -
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... -
ntsiii #2
Re: filterFunction woes
Have you verified that all values of "col" encountered are indeed properties of "item"?
Tracy
ntsiii Guest
-
ntsiii #3
Re: filterFunction woes
Also, please use the "attach Code" button to display code. It is too hard to read otherwise.
Tracy
ntsiii Guest
-
bre358 #4
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



Reply With Quote

