Using Regular Expressions to Filter Arraycollections.

November 23, 2008

Consider we have a requirement like filtering the DataGrid based on some inputs.  Like consider I have a DataGrid and have a DataGridColumn which contains Places list (Bangalore,Delhi,Tirupathi,Chennai…ets).Now that I want to filter this DataGrid upon Places DataGridColumn, based on some TextIput entry.so how am I gonna do this ??.

Here I will show two cases of filtering using the ArrayCollection with RegularExpressions.

I have a ArrayCollection With the Data Like below.

<mx:ArrayCollection id=”prods”>
<mx:Object Artist=”Pavement object killing” Price=”11.99″
Album=”Slanted and Enchanted” />
<mx:Object Artist=”kavement regular expression”
Album=”Brighten the Corners” Price=”11.99″ />
<mx:Object Artist=”Pavement hrule radio” Price=”11.99″
Album=”Slanted and Enchanted” />
<mx:Object Artist=”kavement”
Album=”Brighten the Corners” Price=”11.99″ />
<mx:Object Artist=”Pavement button checkbox” Price=”11.99″
Album=”Slanted and Enchanted” />
<mx:Object Artist=”kavement may be this is”
Album=”Brighten the Corners” Price=”11.99″ />
</mx:ArrayCollection>

Now I want to filter the Artist Column. And  I want 2 cases for filtering or conditions for filtering.

Case 1: The entered text should occur any where in the column data.

For this my Regular Expression would be like below.

new RegExp(sinput.text,”i”)

Here sinput is the id of my TextInput.

Case 2: The column data should start with the entered text.

For this my Regular Expression would be like below.

var strPatt:String=”^”+sinput.text+”";
var newRegEx:RegExp=new RegExp(strPatt,”i”);

Here sinput is the id of my TextInput.

Explore RegularExpression to learn more about them or how to write one.And the best source would the Help from the Flex Builder. And Explore about writing Filter Functions For Arraycollection.

Now Enjoy this Demo Application.

Comment For queries or Code. Enoy the Post. :-)

Updated:

DownLoad source code


Two clearcut,usefull and Good posts.

November 10, 2008

There are two posts which i have been preparing to make, but those same posts where made on different blogs and they are very good and Clear cut description is given by them, so i decided to link those posts here.

1. Installing PHPEclipse plugin in Flex Builder

2. Invoking PHP functions from Flex using AMFPHP

These are really very good posts made. And Finally i would like to thank them for the posts.

Enjoy the post.





Version information in Flex.

November 9, 2008

In Flex Frameworks there is a .as File called Version.as and this contains the Version information for the sdk’s. This is from the package mx.core. Now this Version.as is included in every other Class File in the Flex Frameworks.

Now I got a question here “How I get the Version information from a Flex Application?”.

And Guess what the answer is simple and small as I always told about Flex.

We can retrieve the version information like below .

Var Str:String=”Version No.::”+mx_internal: VERSION;

Enjoy the Post.


Basic info about “degrafa”.[pdf download]

November 6, 2008

If you can atleast go through this pdf file about degrafa Frameworks.Then you will know that they rock.

Download pdf


Skinning controls in Flex using the degrafa Frameworks.

November 4, 2008

Using the Degrafa Framworks[previous post].

I have been skinning controls in Flex using the Degrafa frameworks. Here iam giving out the Button Control and Alert Control with example using the degrafa frameworks. They are amazing.

Run Demo.

Enjoy the post.