Question

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"/>
Was it helpful?

Solution

A DataGrid is designed to inspect Objects and extract data from that Objects readable properties, as you are using Strings 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 Objects 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"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top