In general, a 2d array is not a good dataprovider. However, it is possible. The top-level represents the rows, so there's be a stockinfo in each row. Each row contains four things from the dailyData array? That is a second level object lookup which DataGridColumn does not do. You can use the DeepDataGridColumn from my blog (blogs.adobe.com/aharui) or use labelFunction where the labelFunction pulls data.dailyData[0], data.dailyData[1], etc.
Normally, the top level array contains data objects and the columns pull fields from the objects so stockInfo might have a ADCL, CLAM, CLVO, and WHEN fields. ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jeremy Rottman Sent: Friday, September 14, 2007 7:19 PM To: [email protected] Subject: [flexcoders] Working with dynamic datagrid columns and dynamic data. I am working on an app, where a certain part of the application requires a data grid have dynamic columns. This part of the issue is easy. The hard part of my issue is creating the dataField for these dynamic columns out of a dynamic array that I get back from coldfusion. So with out further ado the code. This is where I am building my array. That I will use to create and populate my datagrid. As you can see it is fairly simply, a 2d array with multiple objects. This array is built and display correctly. private function dailyResult(event:ResultEvent):void{ stockInfo = new Array(); for(var i:int = 0; i < event.result.length;i++){ // top level of stock array stockInfo.push({symbol:event.result[i].SYMB,uuid:event.result[i].STOCKUU ID, dailyData:[]}); // create stock daily items var itemArr:Array = new Array(); for(var k:String in event.result[i].WHEN){ itemArr.push({adcl:event.result[i].ADCL[k],clam:event.result[i].CLAM[k], clvo:event.result[i].CLVO[k],when:event.result[i].WHEN[k]}) } stockInfo[i].dailyData = itemArr; } Debug.show(stockInfo); buildDG() } Here is my buildDG() method. Again fairly simple, I am using the lenght of my previously created array to build the datagrid columns. However it is when I get to this part dgc.dataField = 'open'; is when I get into trouble. The data for the dataField is held in the stockInfo.dailyData.adcl object. And for the life of me I can't see to figure out how to get it to work. private function buildDG():void{ var dgc:DataGridColumn; var aColumnsNew:Array = dg.columns; for(var i:int = 0; i < stockInfo.length;i++){ dgc = new DataGridColumn(); dgc.dataField = 'open'; dgc.width = 30; dgc.headerText = stockInfo[i].symbol; aColumnsNew.push(dgc); //this.addChild(dg); } dg.columns = aColumnsNew; dg.dataProvider = stockInfo; Debug.show(aColumnsNew); } Any help with this would be greatly appreciated.

