Spark DataGrid Change Cell Color

Posted: October 31, 2011 in Flex

Believe it or not, the simple task of changing a cell color when the data is changed (another cell is edited) wasn’t as easy as it might sound. Not just setting it when the grid fills up, but changing it during the course of editing the grid.  Took me a couple weeks to solve.  So, I’m passing it on to you.  Hope it saves you some time!



override public function prepare(hasBeenRecycled:Boolean):void

textColor = 0x000000;

text = data.action;

if(data.action == ’Keep’)
opaqueBackground = 0x00ff00;
else if (data.action == ’Update’){
opaqueBackground = 0xFFCC00;
else if (data.action == ’New’){
opaqueBackground = 0xffff00;
else if (data.action == ’Delete’){
opaqueBackground = 0xff0000;
else {
opaqueBackground = 0x000000;



  1. flextex says:

    There is a bug with spark datagrid opaqueBackground. If your cell color extends into the next column, set the width of the GridItemRender to 100% or a fixed value. This will keep the color inside the cell width.

  2. Geoffrey says:

    Nice! Thanks for the lead on this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s