hi resi,
use the following code
package {
import flash.display.Graphics;
import mx.controls.Alert;
import mx.controls.DataGrid;
import mx.controls.Label;
import mx.controls.dataGridClasses.*;
import mx.core.Application;
public class ItemRen extends Label {
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;
var attribs:XMLList;
var Xml1:XML;
Xml1 = Application.application.myXML;
var
X:XMLList=Xml1.child(childName).Gridvalues.R[DataGridListData(listData).rowIndex].children();
attribs=X[DataGridListData(listData).columnIndex].attributes();
---> you ll get cell values here then check condition
if (attribs[0] > 9 )
{
// Alert.show("inside")
g.beginFill(0xffffff);
g.drawRect(0, 0, unscaledWidth, unscaledHeight);
g.endFill();
}
else if(attribs[0] == "Y" && listData.label !=
"0"){
g.beginFill(0x90EE90);
g.drawRect(0, 0, unscaledWidth, unscaledHeight);
g.endFill();
}
}
}
On Fri, Nov 27, 2009 at 4:30 PM, rishi narang <[email protected]>wrote:
> u need to override the set data method of item renderer
>
>
> On Fri, Nov 27, 2009 at 2:54 PM, Rogelio Canedo
> <[email protected]>wrote:
>
>> Hi,
>> I solicite you because I encounter a problem with an itemRenderer.
>> I develop an application that displays data from a sensor in a DataGrid.
>> there are several changes per second on my dataProvider (ArrayCollection)
>> and I want to put the cell background in green if the value increases or in
>> red if it decrease. Unfortunately, all changes in the dataProvider does not
>> modify the background of my itemRenderer.
>>
>> [BEGIN ItemRenderer]
>>
>> package
>> renderer
>> {
>> import flash.display.Graphics;
>> import flash.events.Event;
>> import mx.controls.Label;
>> import mx.controls.dataGridClasses.*;
>> import mx.events.ResizeEvent;
>> [
>> Style(name="backgroundColor", type="uint", format="Color", inherit="no")]
>> public class BGRenderer extends Label {
>> private var g:Graphics;
>> private var cpt:int = 0;
>> private var old:Number = 0;
>> private var color:uint = 0;
>> public function BGRenderer():void
>> {
>> super();
>> this.addEventListener(ResizeEvent.RESIZE, resize);
>> g = graphics;
>> g.clear();
>> }
>> private function clear(ev:Event):void
>> {
>> if(++cpt == 25)
>> {
>> this.removeEventListener(Event.ENTER_FRAME, clear);
>> g.clear();
>> }
>> }
>> private function resize(ev:ResizeEvent):void
>> {
>> if(color != 0)
>> {
>> g.clear();
>> g.beginFill(color);
>> g.drawRect(0, 0, unscaledWidth, unscaledHeight);
>> g.endFill();
>> }
>> }
>> override protected function updateDisplayList(unscaledWidth:Number,
>> unscaledHeight:Number):void
>> {
>> super.updateDisplayList(unscaledWidth, unscaledHeight);
>> var val:Number = new Number(data[DataGridListData(listData).dataField]);
>> if (!isNaN(val) && val != old)
>> {
>> cpt = 0;
>> this.removeEventListener(Event.ENTER_FRAME, clear);
>> g.clear();
>> if(val < old)
>> {
>> color = 0xFF0000;
>> g.beginFill(0xFF0000);
>> }
>> else
>> {
>> color = 0x00FF00;
>> g.beginFill(0x00FF00);
>> }
>> old = val;
>> g.drawRect(0, 0, unscaledWidth, unscaledHeight);
>> g.endFill();
>> this.addEventListener(Event.ENTER_FRAME, clear);
>> }
>> }
>> }
>> }
>>
>> [END ItemRenderer]
>>
>> to change data in my data provider I use this code:
>>
>> private
>> var valeurDP:ArrayCollection;public
>> function set temperature(val:String, iSonde:Number):void
>> {
>> var tmp:Object = valeurDP[iSonde];
>> tmp.temperature = val;
>> valeurDP.setItemAt(tmp, iSonde);
>> }
>>
>> --
>> 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]<flex_india%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/flex_india?hl=en.
>>
>
> --
> 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]<flex_india%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>
--
Regards,
Sathish. G
Evangelist of Flex,
TamilNadu : 9942350022
Email :[email protected]
:[email protected]
--
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.