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

x
?
Solved

Changing the text color in my Flex DataGrid

Posted on 2009-02-19
3
Medium Priority
?
1,320 Views
Last Modified: 2013-11-11
Hi,

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!
0
Comment
Question by:piyushdabomb
3 Comments
 
LVL 1

Accepted Solution

by:
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">
 
	<mx:Script>
		<![CDATA[
			
			[Bindable] private var xmlData:XML =
				<values>
					<value increased="true">53</value>
					<value increased="false">38</value>
				</values>
			;
						
		]]>
	</mx:Script>
	
	<mx:DataGrid x="20" y="20" id="valuesDataGrid" dataProvider="{xmlData.value}">
		<mx:columns>
			<mx:DataGridColumn headerText="Values">
				<mx:itemRenderer>
					<mx:Component>
						<mx:Text text="{data}" color="{(data.@increased == 'true') ? 0x00FF00 : 0xFF0000 }" paddingLeft="5" />
					</mx:Component>
				</mx:itemRenderer>	
			</mx:DataGridColumn>
		</mx:columns>
	</mx:DataGrid>
	
</mx:Application>

Open in new window

0
 
LVL 19

Expert Comment

by:Jones911
ID: 23688870
Gotta love ternaries.
0
 

Author Closing Comment

by:piyushdabomb
ID: 31548924
Nice.
0

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