ArrayCollection DataGrid filter Example update
July 28th, 2007
**UPDATE**
Thanks to the help of Nolan I was able to get it to:
- works with case-sensitivity
- and resets data as you type.
————————————-
I redid the ArrayCollection example so take a look at this example:
[as]
< ?xml version="1.0" encoding="utf-8"?>
< ![CDATA[
import mx.collections.*;
private var collectionArray:Array;
[Bindable]
private var collectionData:ArrayCollection;
private function init():void
{
collectionArray = [{first: 'Dave', last: 'Matthews'},
{first: 'Dave', last: 'Chappelle'},
{first: 'Amy', last: 'Grant'},
{first: 'Bilbo', last: 'Baggins'},
{first: 'Jessica', last: 'Tandy'},
{first: 'Jessica', last: 'Simpson'},
{first: 'Paris', last: 'Hilton'}];
collectionData = new ArrayCollection(collectionArray);
}
public function filter():void {
collectionData.filterFunction = filterFirst;
collectionData.refresh();
}
public function filterReset():void {
collectionData.filterFunction = null;
collectionData.refresh();
}
private function filterFirst(item:Object):Boolean
{
return item.first.match(new RegExp(searchField.text, 'i'))
//return( item['first'].indexOf( searchField.text ) > -1 );
//return item['first'].match(new RegExp(string, āiā))
}
private function search():void
{
if(searchField.text !=”)
{
filter()
}
else
{
filterReset()
}
}
]]>
[/as]
Last 5 posts in as3
- HOWTO Create a Facebook App using FlexBuilder - June 24th, 2009
- Guitar Synth for Flash - February 27th, 2009
- Abstract Thermometer AIR app - January 22nd, 2009
- Roman Numeral/Arabic Convertion AIR App - Johnny V Now Available - December 25th, 2008
- How to convert Roman Numerals and Arabic numbers in ActionScript 3 - December 17th, 2008
Last 5 posts in Flex
- HOWTO Create a Facebook App using FlexBuilder - June 24th, 2009
- Adobe Evangelist Daniel Dura visits Travelocity - April 15th, 2008
- Yahoo Maps ActionScript 3.0 Released - February 11th, 2008
- Papervision 3D 2.0 / Great White Example - December 26th, 2007
- Tidbit #3 - testing additions to your code - Control Variable - November 28th, 2007
1 Comment Add your own
1. Kenneth | August 13th, 2007 at 12:48 pm
How would I implement this with XML instead of ArrayCollection?
Thanks!
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackback this post | Subscribe to the comments via RSS Feed