SoFunction
Updated on 2025-04-02

Flex DataGrid DataGridColumn Data Color Diversification - Type Replacement


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="/2006/mxml" layout="absolute">

    <mx:Script>
        <!--[CDATA[

        ]]>
    </mx:Script>
    <mx:ArrayCollection >
        <mx:Object>
            <mx:Key>0</mx:Key>
<mx:Value>Close</mx:Value>
        </mx:Object>
        <mx:Object>
            <mx:Key>1</mx:Key>
<mx:Value>Open</mx:Value>
        </mx:Object>
    </mx:ArrayCollection>
    <mx:DataGrid dataProvider="{dataArray}" x="320" y="135">
        <mx:columns>
            <mx:DataGridColumn headerText="Key" dataField="Key" >

            </mx:DataGridColumn>
            <mx:DataGridColumn headerText="Value" dataField="Value" >
                 <mx:itemRenderer>
<mx:Component>
<mx:Label textAlign="center">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
{
= value;
if (=="1")
{
("color","green");
}
else if(=="0"){
("color","red");
}
}
]]-->
</mx:Script>
</mx:Label>
</mx:Component>
    </mx:itemRenderer>    
            </mx:DataGridColumn>
        </mx:columns>
    </mx:DataGrid>
</mx:Application>