If you want to add columns dynamically, you need something like this
var colNum:int=5
for(var i:int=0;i<colNum;i++)
{
var col:DataGridColumn = new DataGridColumn();
col.dataField = "some value1";
col.headerText = "some value2";
myDataGrid.columns.push(col);
}
you'd then generate your dataProvider (could be an ArrayCollection,
Array, XML, whatever)
myDataGrid.dataProvider = myDataProvider;
hope this helps
bh
--- In [email protected], "yossi.baram" <yossi.ba...@...>
wrote:
>
> Hi helper,
> I have a DataGrid and I need to feed its DataProvider dynamically,
> I have difficulties doing that.
>
> my columns:
> var columns:ArrayCollection = new ArrayCollection();
> columns.addItem("parent");
> columns.addItem("cell1");
> columns.addItem("date");
> columns.addItem("cell2");
>
>
> and differnt data for each row.
>
> How do I set all this columns and data (that need to be feed into
> ArrayCollections as well) into a main ArrayCollection
> that will have the following structure?
>
> parent:'root1',col1:100,date:myObject[0],col2:33
> parent:'root1',col1:5,date:myObject[1],col2:21
> parent:'root2',col1:11,date:myObject[2],col2:5
>
>
> Here the column name and values are static, I need all to be
dynamic,
> to be sent to the DataGrid as the DataProvider,
>
> Thanks
>
> Jo
>