I have a DataGrid wired to backend with one field/column as STATUS. The DG uses both CheckBox HeaderRenderer and itemRenderer. When STATUS is "fail", I want to show the checkbox and when it's anything else, not show it (or, as a compromise, disable it). The visible property has no effect whatever (I don't know why) since the checkbox always shows and the enabled=false simply greys it out but still allows the headerRenderer to check & uncheck (again, don't know why). Any idea why this is happening??? Code is quite simple:
itemRenderer -
<?xml version="1.0" encoding="utf-8"?>
<mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import com.fidelity.ORWS.view.requests.RequestStatus;
import mx.controls.Alert;
override public function set data(value:Object):void
{
super.data = value;
this.selected = false;
if(data.status == 'SUCCESS' || data.status == 'PROCESSING')
{ this.enabled = false; }
}
]]>
</mx:Script>
</mx:CheckBox>
HeaderRenderer -
<?xml version="1.0" encoding="utf-8"?>
<mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.DataGrid;
override protected function clickHandler(event:MouseEvent):void
{
super.clickHandler(event);
var dg:DataGrid = this.owner as DataGrid;
var dp:ArrayCollection = dg.dataProvider as ArrayCollection;
var cb:requestcheckboxRenderer;
for ( var i:int=0;i<dp.source.length;i++)
{
cb = dg.indexToItemRenderer(i) as requestcheckboxRenderer;
cb.selected = ( selected ) ? true : false;
}
}
]]>
</mx:Script>
</mx:CheckBox>