0 Replies Latest reply on Aug 7, 2011 6:06 PM by MikePotratz

    Changing a datagrid column image according to the datagrid column value


      Flash Builder 4.5 / SDK 4.5.1.

      Fairly new to Flash Builder & Flex

      Application targets tablets so it's a "mobile" project.

      Been beating my head up against the wall on trying to figure out how to do this. Watched videos on Lynda.com.  Read Adobe "docs" till my eyes glaze over.  Takes me about 2 lines of code in my corresponding .NET project doing the same thing.....

      Tried numerous examples.  Inline rendering, external rendering files per the examples.


      I have a response field in the database and corresponding column in the s:datagrid.  If the "reportInfoResponse" field is null (not answered), show an image with a question mark.  If yes show an image with "Yes" on it.  Same for a no answer.


      I get errors of:

      1120:Access of undefined property negativeAnswer.

      1120:Access of undefined property affirmativeAnswer

      1120:Access of undefined property reportInfoResponse

      1120:Access of undefined property showResponseImage


      If I put this in an external rendering file I also get an error where it can't access the datafield (reportInfoResponse).  I've tried data.reportInfoResponse, {data.reportInfoResponse}, {reportInfoResponse} and just plain reportInfoResponse the external rendering file with no luck.  I've tried single and double quotes around Y and N.  According to all the examples (not to say there aren't more!), I should be able to reference data.reportInfoResponse in the external file and things should be fine.  Of course, the examples are bare bones code and I don't have a clue if any importing of classes or other items need to take place.  I never see any references of such.  The examples also show the image embedding and changing the image by using imageID.source=...  In my code it tells me it can't find it.


      I have put (ERROR HERE...) on the lines where I'm getting the error messages.  I've eliminated a lot of database scripting and such cause that's all working. 


      Any and all suggestions would be appreciated as I'm pulling out what little hair I have left.......and that's not much at my age........  And yes, I probably could do it by just show text in the column, but that's not what the customer wants... There are other columns I need to do this for so I figure if I can get 1 done and working, the rest are a snap.  I CAN use inline or external rendering to show an image.  It's the changing it that is the catch.........


      Thanks in advance!



      <?xml version="1.0" encoding="utf-8"?>

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"




      title="{whichCategoryName} > {whichSubCatName} > Questions">



      import com.adobe.serializers.utility.TypeUtility;

      import flash.data.SQLConnection;

      import flash.data.SQLMode;

      import flash.data.SQLResult;

      import flash.events.StatusEvent;

      import flash.filesystem.File;

      import flash.net.URLRequest;

      import flash.net.URLVariables;

      import flash.net.navigateToURL;

      import flashx.textLayout.tlf_internal;

      import mx.collections.ArrayCollection;

      import mx.core.BitmapAsset;

      import mx.events.FlexEvent;

      import spark.events.GridEvent;

      import spark.events.IndexChangeEvent;


      ...(lots of database coding left out here)


      <s:DataGrid id="showQuestions" width="100%" height="100%"

      creationComplete="Grid_creationCompleteHandler(event)" fontFamily="_sans"

      gridClick="gridClickEvent(event);" horizontalScrollPolicy="off"

      selectionColor="#8AD8EF" selectionMode="singleRow" sortableColumns="false"

      variableRowHeight="true" verticalCenter="middle">



      <s:GridColumn visible="false" dataField="id_report" headerText="id_report" resizable="true" sortable="false"></s:GridColumn>

      <s:GridColumn visible="false" dataField="id_question" headerText="id_question" resizable="true" sortable="false"></s:GridColumn>

      <s:GridColumn id="col_reponse" visible="true" dataField="reportInfoResponse" headerText="Response" resizable="true" sortable="false">








      public var unknownAnswer:Class;



      public var affirmativeAnswer:Class;



      public var negativeAnswer:Class;


      (ERROR HERE - 1120:Access of undefined property reportInfoResponse)

      if(reportInfoResponse == "Y")


      (ERROR HERE - 1120:Access of undefined property showResponseImage)

      showResponseImage.source = affirmativeAnswer;


      (ERROR HERE - 1120:Access of undefined property reportInfoResponse)

      if (reportInfoResponse == "N")


      (ERROR HERE - 1120:Access of undefined property showResponseImage)

      showResponseImage.source = negativeAnswer;





      <s:Image id="showResponseImage" source="{unknownAnswer}" verticalCenter="0" horizontalCenter="0"/>





      <s:GridColumn id="col_question" visible="true" dataField="question" headerText="Question" resizable="true" sortable="false"></s:GridColumn>



      <s:AsyncListView list="{showTheseQuestions}"/>