Ideally you would probably want to make a remote procedure
call to get the schema information for a given domain model which
returns the column names, however, here is a simple example using
e4x to extract the "column" names from some inline XML data.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"initialize="initApp()">
<mx:DataGrid id="customers" />
<mx:XML id="custData" xmlns="">
<customers>
<customer name="Bob" company="Adobe" />
<customer name="Sam" company="Google" />
<customer name="Susan" company="Yahoo" />
</customers>
</mx:XML>
<mx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.List;
private function initApp():void
{
var columnNames:XMLList = custData.customer[0].attributes();
var columnList:Array = [];
for (var i:int=0; i<columnNames.length(); i++)
columnList.push(new DataGridColumn(columnNames
.name()));
customers.columns = columnList;
}
]]>
</mx:Script>
</mx:Application>
Hope that will give you a good start.