This content has been marked as final. Show 4 replies
Using a filterFunction on your ArrayCollection is probably the simplest way to go. I've only glanced at your code, but see if this works for you.
I agree with VarioPegged, with one exception. You need to add a reset on the filter for when the "All" is selected.
I've cleaned up the code a little as well. This should be a lot better than going for the data each time the ComboBox is changed.
I don't know what we noobs would do without the kind people who frequent these forums and give us invaluable help. The help systems are not that smart: I found nothing by searching for things like 'AS 3 data filter', 'Flex filter' and several variations of those; I never thought of 'filter function', much less 'filterFunction' – searching for those, I did find a lot of material. But that's moot when you don't know or think of the term.
TS's reply was exactly what I needed. Re the code for when "All" is selected, I just removed it from the CFC, since Rob added it to the mxml file; now the thing is working like a little Swiss watch. I will put it on the web server after I do some styling and other things.
Rob, you did a lot more than I expected, rewriting the whole Application file – great "customer service".
TS and Rob, thank you very much for all this help. Contact me when you need a recipe. Best regards,
Just to throw in my two cents on this, I do something similar, however, I use a regular expression search. As you can see below it's pretty simple, I"m searching all the fields in my passed in items Object ( which is a row in a datagrid ) case insensitive . So now the user can search for any text in any row / column of my data grid. Using RegExp allows more options if you need when searching text. Here I'm only using case insensitivity but you could easily add masking, or more complicated expressions.
private function filterRoutine( items : Object ) : Boolean
for each( var anItemValue : String in items )
if( anItemValue != null )
if( anItemValue.match( new RegExp(searchField.text, 'i' ) ) )