PDA

View Full Version : how to do this in AS3


digitalnetbizz
05-16-2008, 07:47 AM
I want to construct this in AS3:

<mx:DataGrid id="dataGrid">
<mx:columns>
<mx:DataGridColumn id="timeCol"
dataField="Time"
/>
</mx:columns>
</mx:DataGrid>


I'm doing it with:

var d:DataGridColumn = new DataGridColumn();
d.dataField = "Time";
this.dataGrid.columns.push(d);

This doesnt work?? I looks like it should simulate the MXML above. What am i missing? thanks.

dr_zeus
05-16-2008, 06:51 PM
You might have to explicitly set the columns rather than just pushing a column on the Array. The DataGrid may not be able to detect the push() call.

this.dataGrid.columns = [d];

To add a column later, you could do something like this:

var cols:Array = this.dataGrid.columns.concat(); //make a copy
cols.push(d);
this.dataGrid.columns = cols;