Hi.

I am using item renderer for DataGrids column (for example) derived
from DataGridItemRenderer. The data sent to item renderer has a
boolean property named "valid". If valid == true I want the label to
be red otherwise black. The problem is when I'm using direct
assignment textColor = 0xFF0000; the text doesn't become red. When I'm
using data binding (with data.valid == false) like
<mx:DataGridItemRenderer ... textColor="{highlightColor}">... Where
highlightColor is, for example:

[Bindable]
public var highlightColor : Number;

public override function set data(value : Object) : void {
        if (value != null && value.valid) {
                highlightColor = 0x000000;
        } else {
                highlightColor = 0xFF0000;
        }
        super.data = value;
}

the text still DOESN'T become red.

However if to derive renderer from any container, say Canvas, and
insert Label into that container like:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";>
    <mx:Label color="{highlightColor}" ... />
</mx:Canvas>

with the same highlightColor everything works -- text DOES become red.
I've faced the same behavior in many situations related to item
renderers and list-based controls. E.g. CheckBox or RadioButton need
to be initially checked inside of a list. Every time had to use this
"itemRenderer = control inside of a container + bindable data;"
approach to make it work.

Can't understand why... Seems to me that described above approach is
way to strained. There should be more native one.

Appreciate any help,
R.

Reply via email to