Any help or suggestions with this appreciated. I'm populating
a datagrid control in Flex 2 with dynamically data. The number of
columns and column names aren't fixed. The column data itself is
just raw values; no field names or other elements to identify what
the column header should be.
So when the data provider updates I need to be able to
tweak/add the headerText for the columns. How do I access this
setting through actionscript? I see many examples for defining
<mx.DataGridcolumn> and properties, but I can't really do it
that statically in advance; I don't know the column count or type
of columns until runtime.
Is it possible to access the headerText property with
something like dataGridID.column.DataGridColumn.headerText = ""?
This is what I'm looking for, the ability to iterate through and
set the headerText, but I haven't found the magic incantation.
You can access the columns through the dataGrid.columns array
Get a reference to that array from the DG into a variable,
modify the column elements as desired through that var, then
re-assign the var to the dg.columns property. So you are close:
var aColumns:Array = dataGridID.columns;
var dgc:DataGridColumn = aColumns;
dgc.headerText = "this is column 1";
dataGridID.columns = aColumns; //this step is required!