2 Replies Latest reply on Jun 29, 2007 12:19 PM by SaltedIceCream

    DataGrid having a dataField as an AS object

    SaltedIceCream
      I have a DataGrid with a dataProvider of an ArrayCollection of these objects:

      package uiowa.dpte.biz
      {
      [Managed]
      [RemoteClass(alias="uiowa.dpte.biz.AlternativeToAttribute")]
      public class AlternativeToAttribute
      {
      public var id:int;
      public var rating:Number;
      public var currentAlternative:uiowa.dpte.biz.Alternative;
      public var currentAttribute:uiowa.dpte.biz.Attribute;
      }
      }

      The Attribute object:

      package uiowa.dpte.biz
      {
      import mx.collections.ArrayCollection;

      [Managed]
      [RemoteClass(alias="uiowa.dpte.biz.Attribute")]
      public class Attribute
      {
      public var attributeId:int;
      public var alternativeToAttributes:ArrayCollection;
      public var name:String;
      }
      }

      Everything loads fine except the currentAttribute.name for one of the DataGridColumn dataFields.

      <mx:DataGrid width="432" height="150" dataProvider="{alternativesToAttributes}"
      id="dgAltToAtr" editable="true" mouseDown="Alert.show(dgAltToAtr.selectedItem.currentAttribute.name)">
      <mx:columns>
      <mx:DataGridColumn headerText="id" dataField="id" editable="false"/>
      <mx:DataGridColumn headerText="rating" dataField="rating" editable="true"/>
      <mx:DataGridColumn headerText="name" dataField="currentAttribute.name" editable="false">
      </mx:DataGridColumn>
      </mx:columns>
      </mx:DataGrid>

      For testing purposes I have the "Alert.Show" on mousedown in the grid which does work correctly. I'm shown the correct currentAttibute.name when something is slected.

      Is my syntax incorrect for the currentAttribute.name in the dataField or something?

      Thanks!

      Andrew R
      The University of Iowa