3 Replies Latest reply on Sep 15, 2010 12:23 AM by gl@hw

    ItemRenderer Issue with DataGrid and Label

    gl@hw
      <mx:DataGrid width="100%" height="100%" rowCount="5" dataProvider="{publish_status}">
           <mx:columns>
                <mx:DataGridColumn dataField="status" headerText="Status">
                     <mx:itemRenderer>                         
                          <fx:Component>
                               <mx:Label text="{data.status}" fontSize="12">
                                    <fx:Script>
                                         <![CDATA[
                                         override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
      
                                         super.updateDisplayList(unscaledWidth, unscaledHeight);
                                         
                                         if(this.text == "A"){
                                              setStyle("color", "blue");
                                         }                              
                                         else if(this.text == "B"){
                                                   setStyle("color", "green");
                                         }
                                         else if(this.text == "C"){
                                              setStyle("color", "red");
                                         }
                                         else{
                                              setStyle("color","white");
                                         }
      
                                         }
                                         ]]>
                                    </fx:Script>
                               </mx:Label>                                             
                          </fx:Component>                              
                     </mx:itemRenderer>
                </mx:DataGridColumn>
           </mx:columns>
      </mx:DataGrid>
      

       

       

      I created an inline ItemRenderer as above. I understand that it gets recycled and have included the last "else" statement to return color to default if all tests fail.  The problem is that the text is still showing up in the wrong colors.  I have done a lot of reading on the forums but I can't figure out what I'm missing.


      Thanks.


      Btw, I am using Flash Builder 4.