3 Replies Latest reply on Mar 2, 2010 3:19 AM by RonnieCR7

    Trouble using item renderer insid datagrid to display icons.

    RonnieCR7 Level 1

      Hi,
      I am trying to use an inline itemrenderer to display an image and a label in a datagrid column. I use a dynamic XML to load the datagrid. But somehow it doesnt seem to work for me. Please let me know where i am commiting a mistake.

       

       

      My Datagrid:

      <mx:DataGridColumn>
      <mx:itemRenderer>
      <mx:Component>
      <mx:HBox verticalGap="2">
      <mx:Image source="{data.setIcons()}" />
      <mx:Label text="{data.type}"/>
      </mx:HBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>

       

       

      Action Script:

       

      private function setIcons():String {

       

      var image:String;
      var type:String = errorList.type;

       

      switch (type) {

       

      case "ERROR":
      image = "assets\images\error.jpg";
      break;

       

      case "WARNING":
      image = "assets\images\warning.jpg";
      break;

       

      default:
      break;

       

      }

       

      return image;

       

      }

       

      private function errorReportHandler(event:ResultEvent):void
      {
      errorList = event.result.sample;
      }

       

       

      I have tried to specify the source of the image as :

       

      <mx:Image id="dgImage" source="\assets\images\{toLowerCase(data.type)}.jpg" />

       

      But still it jus shows a greyish image with nothin in it... it s kind of silver greyish in color and shows nothin.

       

      I have even tried to embed the images in a class and refer them accordingly based on the 'type', but it also didnt work.

      Could someone plz tel me wat im missing?

      Thanks in advance.