Monday, January 3, 2011

Handle Data Display in DataGridColumn of Flex DataGrid When Data in embedded object within object

suppose the data received is var data:ArrayCollection, data being set to the array of object DataObject defined as

  public class DataObject {
    private var _objName : String;
    
    public function get objName() : String {
       return _objName;
    }

    public function set objName(value : String) : void {
      _objName = value;
    }

    private var _property : EmbeddedObject;
    
    public function property() : EmbeddedObject {
      return _property;
    }

    public function set property(value : EmbeddedObject) : void {
      _property = value;
    }

and EmbeddedObject being defined as

  public class EmbeddedObject {
    private var _embeddedObjName : String;

    public function get embeddedObjName() : String { 
      return _embeddedObjName; 
    }
      
    public function set embeddedObjName(value:String) : void {
      _embeddedObjName = value;
    }
}

Now when you want to display the variable from EmbeddedObject you can do following:

  <mx:DataGridColumn dataField="objName" headerText="objName"/>
  <mx:DataGridColumn dataField="property.embeddedObjName" headerText="embeddedObjName"/>








No comments:

Post a Comment