PDA

View Full Version : Datagrid question


Wolf Hound
06-12-2009, 01:57 PM
Hello everyone, I'm new to the forum and for that matter, new to Flex. I'm sure this is a basic question, but I'm stumped and can't seem to find an answer.

When I test my ArrayCollection object with this code, it seems to display the data fine:
<mx:DataGrid id="myDG" dataProvider="{infoDataDisplay}" width="100%">
</mx:DataGrid>

However, when I specify the columns in the code below, it sticks the data in the headers rather than the body:
<mx:DataGrid id="myDG" dataProvider="{infoDataDisplay}" width="100%">
<mx:columns>
<mx:DataGridColumn dataField="{infoDataDisplay.field}"/>
<mx:DataGridColumn dataField="{infoDataDisplay.value}"/>
</mx:columns>
</mx:DataGrid>

Can someone please explain what I'm doing wrong here? I've attached screen captures of the results.

thanks!
-Adam

mattb
06-13-2009, 04:05 AM
You probably want to use something like this:


<mx:DataGrid id="myDG" dataProvider="{infoDataDisplay}" width="100%">
<mx:columns>
<mx:DataGridColumn dataField="field" headerText="Field Column"/>
<mx:DataGridColumn dataField="value" headerText="Value Column"/>
</mx:columns>
</mx:DataGrid>

Wolf Hound
06-13-2009, 04:27 AM
That was it. Thanks Matt! I figured it was something easy like that, but couldn't wrap my mind around it for some reason.

-Adam