1 Reply Latest reply on Apr 9, 2007 10:46 AM by peterent

    Datagrids and Dynamic Images

    poze9
      Need some help with this one for sure. I have a small table in SQL that I'm using as the backend database for this application. The table consists of a few columns, one of which is a path to a local image for that particular database entry (more specifically a product image) . I have attached a sample of code that I'm using to pull the data back into the datagrid, but can't seem to understand how to set the image source property based on the data I get back from the database.

      The database column that contains the path is called ImagePath. I'm trying to use a itemRenderer to accomplish this but I may be off base.

      <mx:DataGrid x="0" y="0" width="100%" id="DGProducts" height="100%" dataProvider="{flexcomm.XMLData.results.record}" editable="false" verticalScrollPolicy="auto" itemClick="itemClickEvent(event)">
      <mx:columns>
      <mx:DataGridColumn headerText="Product Image" dataField="ImagePath" textAlign="center">
      <mx:itemRenderer>
      <mx:Component>
      <mx:VBox horizontalAlign="center">
      <mx:Image source=" ? Need help here ">
      </mx:Image> </mx:VBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
      <mx:DataGridColumn id="Product" headerText="Product" dataField="Product" wordWrap="true"/>
      <mx:DataGridColumn headerText="Description" dataField="Description" wordWrap="true"/>
      <mx:DataGridColumn headerText="Indications" dataField="Indications" wordWrap="true"/>
      <mx:DataGridColumn headerText="Coverage" dataField="Coverage" wordWrap="true"/>
      </mx:columns>
      </mx:DataGrid>

      Any help would be greatly appreciated !
        • 1. Re: Datagrids and Dynamic Images
          peterent Level 2
          What does a <record> element look like? Where in that <record> element is the path to the image? If it were like this:

          <record>
          <image>path_is_here</image>
          ...
          </record>

          Then use <mx:Image source="{data.image}" ... />

          If the data is like this:

          <record imagePath="path_to_image" >
          ...
          </record>

          Then use <mx:Image source="{data.@imagePath}" ... />