*Thanks* to everyone for all the valuable replies.

I have implemented somewhat similar with the help of your guidance. But I am
able to do it for static value comparision. Now I want to perform the same
functionality for dynamic values with which data fields can be compared in
ItemRenderer. For this I made one *property* in the item renderer so that
dynamically it can be set from the main mxml file. But I am facing problem
in this. I am not getting how to set the property of item renderer
dynamically from main mxml file. I tried the following code :

*CustomBackgroundColor.as*

package {

import mx.controls.Label;

import mx.controls.DataGrid;

import mx.controls.dataGridClasses.*;

import flash.display.Graphics;

import mx.controls.Alert;

public class CustomBackgroundComp extends Label {

private var _threshold:Number;

override protected function
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {

super.updateDisplayList(unscaledWidth, unscaledHeight);

var g:Graphics = graphics;

g.clear();

var grid1:DataGrid = DataGrid(DataGridListData(listData).owner);

if (grid1.isItemSelected(data) || grid1.isItemHighlighted(data))

return;

if (data[DataGridListData(listData).dataField] > _threshold)  {

g.beginFill(0xFF0033);

g.drawRect(0, 0, unscaledWidth, unscaledHeight);

g.endFill();

} }

public function set threshold(value:Number):void  {

_threshold = value;

} } }



*Main.mxml *

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute"
initialize="" xmlns="*" >

<mx:Script> <![CDATA[

import mx.collections.ArrayCollection;

import mx.rpc.events.ResultEvent;

import mx.controls.Alert;

import mx.core.ClassFactory;

private var employeeData:ArrayCollection=new ArrayCollection();

private function resultHandler(event:ResultEvent):void {

employeeData = event.result.coordinates.values;

} ]]> </mx:Script>

<mx:HTTPService id="employeeService"  url="data/file.xml"
result="resultHandler(event)" />

<mx:DataGrid id="dg" x="0" y="0" width="100%" initialize="inii()"
dataProvider="{employeeData}" >

<mx:columns>

<mx:Array>

<mx:DataGridColumn dataField="xval" headerText="x value"
itemRenderer="CustomBackgroundComp"/>

<mx:DataGridColumn dataField="yval" itemRenderer="CustomBackgroundComp"
headerText="y value" />

</mx:Array>

</mx:columns> </mx:DataGrid>

<mx:Button x="60" y="248" label="Get Result" click="employeeService.send();"
/>

</mx:Application>



Please guide me for this. Thanks,

Deepak

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to