I have a simple array of objects:
public var activityArray:Array=["a1", "a2", "a3", "a4"];
How would I basically put this into a data-grid column? I have set up the datagrid as part of it is shown below:
</mx:HBox>
<components:PortalTabGridCanvas id="marketPlansGridCanv" height="33%" width="98.5%">
<mx:AdvancedDataGrid id="marketPlansGrid" height="100%" width="100%" dataProvider="activityArray">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="{Mlc.curr.get('Activity Type')}" width="160" dataField="ATTRIB_VALUE" textAlign="center" headerWordWrap="true"/>
<mx:AdvancedDataGridColumn headerText="{Mlc.curr.get('Activity')}" width="160" dataField="ATTRIB_VALUE" textAlign="center" headerWordWrap="true"/>
A DataGrid
is designed to inspect Object
s and extract data from that Object
s readable properties, as you are using String
s in your dataProvider
, there are no properties to read.
To display data from an Object
in an AdvancedDataGridColumn
, the columns dataField
must be the name a readable property from that Object
.
You would need to define your dataProvider
to contain Object
s at a minimum like the below example.
public var activityArray:Array =
[
{
property1:"a1",
property2:"a1's second property"
} ,
{
property1:"a2",
property2:"a2's second property"
}
//etc, etc, etc...
];
And then define your columns like:
<mx:AdvancedDataGridColumn headerText="{Mlc.curr.get('Activity Type')}" width="160" dataField="property1" textAlign="center" headerWordWrap="true"/>
<mx:AdvancedDataGridColumn headerText="{Mlc.curr.get('Activity')}" width="160" dataField="property2" textAlign="center" headerWordWrap="true"/>