I've been using this code below for a long time...but don't fully
understand how it works:) It does work great, as long as both title
and docNumber are not null. But it blows up if docNumber is null.
1) Can someone explain in words what indexOf does? Obviously it
compares the two and spits out a number, but I just don't fully grasp
what is going on. Why use it instead of just == ?
2) The OR || isn't clicking either. Would I add !item.docNumber.length
as another || to prevent the error when docNumber is blank? I want it
to filter on one or more columns in the dataProvider, but not blow up
if any one of them are blank. If one is blank, it should still filter
on the others.
public function processFilter(item:Object):Boolean
{
var result:Boolean=false;
// If no filter text, or a match, then true
if (!item.title.length
|| item.title.toUpperCase().indexOf(term.text.toUpperCase()) >= 0
||item.docNumber.toUpperCase().indexOf(term.text.toUpperCase()) >= 0
)
result=true;
return result;
}
Thanks for the added insight into this borrowed code.:)
Don