> Can I set it dynamically without the need to set
> columnName:columnValue statically?
Sorry i'm a bit unclear. Another suggestion ...
You want to create DatgridColumns based on whats in the DataProvider.
If your dataProvider Array is something like the following
var myArray:Array =
[{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}];
then why not do something like this
var row:Object = myArray[0];
for(var obj1:Object in row)
{
var col:DataGridColumn = new DataGridColumn();
col.dataField = obj1;
}
--- In [email protected], "yossi.baram" <yossi.ba...@...>
wrote:
>
> Thanks man,
>
> I am doing something like you mensioned for columns,
> my problem is the dataprovider itself that I set to the DataGrid.
> Can I set it dynamically without the need to set
> columnName:columnValue statically?
> To be clear :)
> My current dataprovider is set accornigly in an Array:
> {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}
>
>
> I need to build it dymanically because the column names(the ones
> before the semicolon) can be different and as I said I get them and
> the values(objects) from Arrays.
>
> Thanks again
>
> Jo
>
>
>
> --- In [email protected], "bhaq1972" <mbhaque@> wrote:
> >
> > 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.baram@>
> > 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
> > >
> >
>