1 Reply Latest reply on Jun 1, 2010 10:22 PM by Miggl

    Custom ItemRenderer with dynamic field associations?

    Miggl Level 1

      Hi All,


      I'm trying to create a custom itemrender control that isn't tied to a specific type of data input. I'm creating a thumbnail itemrenderer to be used with the Sparks List control:


      <?xml version="1.0" encoding="utf-8"?>
      http://ns.adobe.com/mxml/2009" xmlns:s="
      library://ns.adobe.com/flex/spark" xmlns:mx="
      library://ns.adobe.com/flex/mx" autoDrawBackground="
      <mx:Image left="
      5" right="
      5" bottom="
      25" top="
      5" id="
      5" right="
      5" bottom="
      5" verticalAlign="
      middle" textAlign="
      center" id="
      lbl_label" fontWeight="
      bold" fontSize="

      However, as you can see, the image source and label text properties are tied to specific fields in the data collection (image and label). I would like to provide a way to figure out what the label and icon fields are set to in the parent control, and set them accordingly in the itemrenderer. This should allow me to use the same itemrenderer with different objects, as long as they have a text and image property.


      Any ideas? Thanks

        • 1. Re: Custom ItemRenderer with dynamic field associations?
          Miggl Level 1

          After doing some research, I found my answer:


          1) The data object is the current item which the List component is populated with. You can access any properties of the object using it. (Not what I'm looking for here.)


          2) You can access the label property set by the labelField or labelFunction properties of the list control in the item renderer simply using this.label. This is exactly what I was looking for.