This content has been marked as final. Show 8 replies
You can use an itemrenderer, the adobe docs have extensive documentation on how to use itemrenderer's in a datagrid
i know itemrenderers are necessary however i can't figure out how to make the different image pop in, in regards to the value(t or f) of the column
make your item renderer a canvas, with 2 images.
when your canvas loads, you have the 'data' of that cell. So lets say your column's datafield is "hasimage", you can do something like this:
<mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="created();">
override public function set data(value:Object):void
if(value != null)
super.data = value;
public function created():void
if(data["hasimage"] == "true")
trueImg.visible = true;
falseImg.visible = true;
<mx:Image id="trueImg" src="image" visible="false" />
<mx:Image id="falseImg" src="image" visible="false" />
This example is a bit contrived, but may be of some use. Not sure why I can't use data == 'true' instead of data.Good == 'true'
Thanks Greg, works exactly like i want it to. The only difference is in my code the true/false is a Boolean value and not a string. I wasn't aware you could use the conditional operator in the source. Big help.
I tried to get it to work with Boolean, but could not and did not have time to dig deeper. If you figure that out please share. Thanks!
your code works fine if you just make the string 'true' and 'false' just true and false (which turn them blue and makes them the bool values) and do the same with the compare in the image source. It outputs the correct image to the data field just as the string version did.
Oh yeah. That didn't work for me last time I tried. Kool.