Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Changing the text color in my Flex DataGrid

Posted on 2009-02-19
Medium Priority
Last Modified: 2013-11-11

I have a DataGrid that is populated from a datasource. In one of the columns, I only have 2 entries: "Increased" and "Decreased". If the value is decreased, I want to change the color text to "red" and if the value is "increased", I want to change the color value to "green".

I would like to do this in action script and after looking online for 2 hours, I found nothing that actually works. Can I ask you to please give me a sample *.mxml file and maybe even an *.xml file that works that I can play with?

Any help is greatly appreciated. Thanks!
Question by:piyushdabomb

Accepted Solution

OlaMuldal earned 2000 total points
ID: 23688349
This MXML should give you enough clues to adjust to you needs i hope :-)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
			[Bindable] private var xmlData:XML =
					<value increased="true">53</value>
					<value increased="false">38</value>
	<mx:DataGrid x="20" y="20" id="valuesDataGrid" dataProvider="{xmlData.value}">
			<mx:DataGridColumn headerText="Values">
						<mx:Text text="{data}" color="{(data.@increased == 'true') ? 0x00FF00 : 0xFF0000 }" paddingLeft="5" />

Open in new window

LVL 19

Expert Comment

ID: 23688870
Gotta love ternaries.

Author Closing Comment

ID: 31548924

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question