I’m trying to alternate between two background colors for each cell in a datagrid. It changes its state upon double clicking in a particular cell.
What I want is that the user be able to select individuals cell in a Datagrid so #FFFFFF color is for unselected cells and #CDCDCD for selected ones.
I have the following code for an ItenRenderer:
<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
clipAndEnableScrolling="true">
<fx:Script>
<![CDATA[
override public function prepare(hasBeenRecycled:Boolean):void {
//lblData.text = data[column.dataField]
}
]]>
</fx:Script>
<s:states>
<s:State name="normal"/>
<s:State name="selected"/>
</s:states>
<s:Label id="lblData" top="9" left="7" text="10" width="100%" height="100%" textAlign="center"/>
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color.selected="#CDCDCD" color.normal="#FFFFFF"/>
</s:fill>
</s:Rect>
</s:GridItemRenderer>
The question is that label is never shown due to the rect component hide it. how can i accomplish this?
Thanks in advance.
Try this:
//Application
//Renderer
//EDIT
Here you can see my screenshot for data[column.dataField] problem:
Here is the coresponding value object
So data[column.dataField] = data[“Artist”] = “01”