3 Replies Latest reply on Jul 15, 2011 1:19 AM by mikmiki

    Compare last and new value on a spark DataGrid cell

    mikmiki Level 1

      Hi,

      i want to compare the last value that was on a spark data grid cell to the new value and paint the label- if lower to red and if bigger to green.

      i all ready have an grid item renderer as follows to paint even and odd rows in a different color.

      <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[

       

       

      import mx.collections.ArrayCollection;

       

      import spark.components.Grid;

       

      override public function prepare(hasBeenRecycled:Boolean):void {

      lblData.text = data[column.dataField]

      }

       

       

      override public function set data(value:Object):void

      {

       

       

      super.data = value;

       

      var myOwner = super.grid as Grid;

       

       

      var myOwnerDataProvider:ArrayCollection = myOwner.dataProvider as ArrayCollection;

       

       

      var myIndex:int = myOwnerDataProvider.getItemIndex( data );

       

      var i : uint;

       

      if(myIndex % 2 == 0)

      {

       

      c.color=0x525252;

       

      }

       

      else

      {

      c.color=0x2C2C2C;

      }

       

      }

       

       

      ]]>

       

       

      </fx:Script>

       

      <s:Rect id="rect" top="0" bottom="0" right="0" left="0">

       

      <s:fill>

       

      <s:SolidColor id="c" color="#2C2C2C"/>

       

      </s:fill>

       

      </s:Rect>

       

      <s:Label id="lblData" textAlign="center" color="#DADADA" alpha="0.5" top="20" left="20"/>

      </s:GridItemRenderer>

       

      any ideas?