Skip navigation
DJH_EOS
Currently Being Moderated

How do I reference the data object in a DataGrid to show an image correctly in Acrobat?

Sep 19, 2013 12:00 PM

Tags: #error #xml #4.5 #spark #flex4.5

I'm creating an inferface for an Acrobat application  and I'm having a issue with displaying an image in a grid.  When I hard code the source="statusNONE.png" it works as intended (with an image, not the image associated with each grid item), however, when I try to use the source="{data.@icon}" to reference the dataProvider (XMLListCollection) I get nothing.  Not a broken image or anything.  I think I may just not be referencing the XMLListCollection correctly, otherwise I don't know why it would work with hard coding vs. fetching the string from the XML.

 

//Application Header (Flex 4.5)

 

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                 xmlns:s="library://ns.adobe.com/flex/spark"
                                 xmlns:mx="library://ns.adobe.com/flex/mx"
                                 width="100%" height="100%" creationComplete="eaton_creationCompleteHandler(event)"
                                 currentState="Review">

 

//Sample of XML that gets used as basis for XMLListCollection

<Annots>
     <Annot name='TEST' index='14' feedback='' canConstruct='0' icon='statusNONE.png'/>
</Annots>

 

//creation of the XMLListCollection from String

 

[Bindable] protected var fullXML:XML;

[Bindable] protected var fullXMLCol:XMLListCollection;

 

protected function loadXML(xmlString:String):void

{

      fullXML = new XML(xmlString);

     var fullXMLList:XMLList = fullXML.children();

      fullXMLCol = new XMLListCollection(fullXMLList);

}

 

//DataGrid

<s:DataGrid left="0" top="0" bottom="0" width="142" dataProvider="{fullXMLCol}"
                                        requestedRowCount="4" rowHeight="30"
                                        top.Confirm="87">
                    <s:columns>
                              <s:ArrayList>
                                        <s:GridColumn dataField="@name" headerText="Annotations"></s:GridColumn>
                                        <s:GridColumn headerText="status" width="30" >
                                                  <s:itemRenderer>
                                                            <fx:Component>
                                                                      <s:GridItemRenderer>
                                                                                <s:Image width="30" height="30" source="{data.@icon}"/> //THIS IS THE PART THAT SEEMS TO BE GIVNG ME TROUBLE!
                                                                      </s:GridItemRenderer>
                                                            </fx:Component>
                                                  </s:itemRenderer>
                                        </s:GridColumn>
                              </s:ArrayList>
                    </s:columns>
                    <s:typicalItem>
                              <fx:Object dataField1="Sample Data" dataField2="Sample Data" dataField3="Sample Data"></fx:Object>
                    </s:typicalItem>
          </s:DataGrid>

 

Additional information.  I'm using the resources tab for the flash embedding in Acrobat for my images. This works when I am hard coding the file name string works for the source without having to add a full path, the images are not technically bundled into the swf.   I just don't understand why using the data object to get that same string would show different results.

 

tl;dr: GridItemRenderer works to show images when hard coded but not when using {data}.

 

UPDATE: Figured it out, needed to add a toString() to the data.@icon.   I had assumed it was a string being handed over, I assumed wrong.

 
Replies
  • Currently Being Moderated
    Sep 19, 2013 1:36 PM   in reply to DJH_EOS

    Probably because data.@icon isn't a String, it is an XMLList, and source property is an Object not a String so the runtime doesn't automatically convert it.

      Try data.@icon.toString()

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points