0 Replies Latest reply on May 6, 2011 10:48 AM by crissy84

    Binding an XML Transformation?

    crissy84

      Hi,

      Let's say I have a colleciton of  (Car) objects.  Each object has an XML property on it ("description").  Now I'm going to bind this collection to a List control and I want the "description" property to be the labelField.  However, this data is XML and I don't want to show raw XML, I want to transform this XML to a user-friendly format.

      The way I currently do this, is I have function in my Car class (getDescriptionText()) and I use a labelFunction instead of labelField.  So the List renderer calls this getDescriptionText() and displays what I want.  This works, except for the binding.  When I make a change in the description/xml on the object, the new label text is not automatically updated in the List control.

       

      <s:List 
      dataProvider="{this.cars}"
      labelFunction="{function(item:Car):String{return item.getDescriptionText();}}"
      />     
      

       

      public class Car
      {
           public function getDescriptionText():String
           {
                return this.description.@color + ' ' + this.description.@type; // (very simplified example)
           }
      }
      

       

      Any ideas on how I can make this type of binding work?

       

      Thank you!