I have some sample code in 1.5:
public static function buildPhasesDataGridColumns():Void
{
Dumper.info("%%%%%%%%%%% buildPhasesDataGridColumns invoked");
var phasesVOArray : Array = ModelLocator.currentProject.phaseVOArray;
ModelLocator.phasesDG.removeAllColumns();
for ( var i:Number=0; i< phasesVOArray.length; i++ ) {
var dgcNew = new mx.controls.gridclasses.DataGridColumn(); //now create the column
var date : String = VirgilUtil.nextWeekEndDateStr(ModelLocator.currentProject.projectStartDate, i);
dgcNew.width = Constants.WEEK_COLUMN_WIDTH * (Number(phasesVOArray[i].numWeeks));
dgcNew.columnName = i + 1;
dgcNew.headerText = phasesVOArray[i].phaseName + " " + i;
dgcNew.headerRenderer = ui.PhasesColumnHeaderRenderer;
ModelLocator.phasesDG.addColumn(dgcNew); //add the column to the dg
Dumper.info("%%%%%%%%%%% Adding column at:" + (i));
}
ModelLocator.phasesDG.width = Number(ModelLocator.currentProject.numWeeks) * 170;
}
{
Dumper.info("%%%%%%%%%%% buildPhasesDataGridColumns invoked");
var phasesVOArray : Array = ModelLocator.currentProject.phaseVOArray;
ModelLocator.phasesDG.removeAllColumns();
for ( var i:Number=0; i< phasesVOArray.length; i++ ) {
var dgcNew = new mx.controls.gridclasses.DataGridColumn(); //now create the column
var date : String = VirgilUtil.nextWeekEndDateStr(ModelLocator.currentProject.projectStartDate, i);
dgcNew.width = Constants.WEEK_COLUMN_WIDTH * (Number(phasesVOArray[i].numWeeks));
dgcNew.columnName = i + 1;
dgcNew.headerText = phasesVOArray[i].phaseName + " " + i;
dgcNew.headerRenderer = ui.PhasesColumnHeaderRenderer;
ModelLocator.phasesDG.addColumn(dgcNew); //add the column to the dg
Dumper.info("%%%%%%%%%%% Adding column at:" + (i));
}
ModelLocator.phasesDG.width = Number(ModelLocator.currentProject.numWeeks) * 170;
}
--- In [email protected], "jameskeepnews" <[EMAIL PROTECTED]> wrote:
>
> Hello. I am very new to Flex -- and we're running the 2.0 Beta now,
> knowing that we'll have to migrate to it eventually -- and was never
> an enterprise-class ActionScript developer in Flash anyway, so
> forgive me if my two questions seem very simple to some of you.
> Nevertheless, I haven't seen a satisfactory answer to either
> question here, or anywhere else online.
>
> First question -- how could I dynamically generate an array of
> DataGridColumns? Suppose I have the following:
>
>
> <mx:DataGrid id="grid_01">
> <mx:dataProvider>{ someProvider }</mx:dataProvider>
>
> .....
>
> </mx:DataGrid>
>
>
> and, in place of those "dots," I'd want to have the following
> results returned from "someProvider":
>
>
> <mx:columns>
> <mx:Array>
>
> <mx:DataGridColumn columnName="gridcol_01" headerText="First
> Column" textAlign="middle" />
> <mx:DataGridColumn columnName="gridcol_02" headerText="Second
> Column" textAlign="middle" />
> <mx:DataGridColumn columnName="gridcol_03" headerText="Third
> Column" textAlign="middle" />
> <mx:DataGridColumn etc. />
>
> </mx:Array>
> </mx:columns>
>
>
> Could someone provide me with sample code for how to build out the
> data provider so that those results might be returned?
>
> Lastly, coming from a mouseDown/getURL sensibility in Flash, I'm a
> little mystified by the way in which DataGrid cells -- or rows, in
> my case -- can simply serve as links. In my case, I'd want a rolled-
> over row to call a different viewstack when clicked. Obviously, if
> I'm generating the DataGrid dynamically, I won't have an automatic
> reference to anything in my Datagrid within MXML. Also, I believe I
> need to generate a cellRenderer to accomplish
> a "stack.selectedChild=nameofstack" result for what is (to me) a
> souped-up link. I've seen cellRenderer do impressive dynamic tricks,
> EXCEPT linking to something! And, to reiterate, I'm looking to have
> an entire row be a hyperlink, much as the DataGrid allows for a
> rollover state for rows and would, from our users' perspective, be
> seen as results of a search, arranged into a handy grid -- and rows
> that should link to something else when clicked.
>
> Any help that could be provided would be very much appreciated.
> Thank you for your attention.
>
> James
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

