0 Replies Latest reply on Aug 12, 2011 5:23 AM by nikos101

    spark datagrid that shows the new  value and that it previously was

    nikos101 Level 2

      Im trying to create a item renderer for a spark datagrid that shows the new  value and that it previously was and I am comparing in the set data, the problem I am having is that in teh set data I am frequently getting data from other rows (I know this because of virtual renderders), it there a way round this?

       

      <?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"
                          currentState="unmodified">
         
         
          <fx:Script>
              <![CDATA[
                  override public function set data(value:Object):void
                  {
                      if(data){
                          if(super.data.margin != value.margin  && super.data.margin){
                              oldValue.text = '(' + super.data.margin + ')';
                          }else{
                              oldValue.text == '';
                          }
                      }
                     
                      super.data = value;
                     
                      stroke.visible = false;
                      fillRect.visible = false;
                     
                     
                      if(data){
                          if(this.data.isModifiedClientSide){
                              currentState = "modified";
                              fill.color = 0xddddff;
                             
                              stroke.visible = true;
                              fillRect.visible = true;
                          }
                          else{
                              fill.color = 0xffffff;
                              stroke.visible = false;
                              currentState = "unmodified";
                              fillRect.visible = true;
                          }
                      }
                     
                     
                  }
              ]]>
          </fx:Script>
          <s:states>
              <s:State name="modified"/>
              <s:State name="unmodified"/>
          </s:states>
          <s:Rect top="0" left="0" right="0" bottom="0" id="fillRect" >
              <s:fill><s:SolidColor id="fill"  color="0xFFffff"  /></s:fill>
          </s:Rect>
         
         
         
         
          <s:Rect left="1" top="1" right="0" bottom="0" id="stroke">
              <s:stroke >
                  <s:SolidColorStroke color="0x000099" weight="1"  >
                     
                  </s:SolidColorStroke>
              </s:stroke>
          </s:Rect>
         
         
         
          <s:HGroup horizontalAlign="center" verticalAlign="middle" top="0" left="0" right="0" bottom="0" paddingRight="5">
              <s:Label text="{data.margin}" width="50%" textAlign="right">
                 
              </s:Label>
              <s:Label  id="oldValue" color="0xff0000" width="50%"  textAlign="right">
                 
              </s:Label>
             
             
          </s:HGroup>
         
         
      </s:GridItemRenderer>