Ignore my last posting saying removing the column tags didn't work. I 
went back in and tried again and it worked fine this time! All 
columns showed.  No idea why it didn't work last night.
Thanks!
Don

--- In [email protected], "Doug Lowder" <[EMAIL PROTECTED]> 
wrote:
>
> Hi Don,
> 
> If you remove the columns specification from the mxml of your 
> DataGrid declaration, I believe the grid should show all fields of 
> your dataprovider by default.  In that case, your DataGrid would 
> look like the following:
> 
> <mx:DataGrid editable="true" 
>  alternatingItemColors="[#ece8ff, #ffffff]" id="cfgrid" 
>  width="100%" height="190" alpha="1.0" />
> 
> If you need greater control over which specific fields are to be 
> displayed in the grid, you can create the grid column objects 
> dynamically in the getQuery_result() function and assign an array 
> populated with those objects to the grid's columns property. That 
> code would look something like the following:
> 
> var myColumns: Array = [];
> // maybe in some sort of loop based on RO results
> var myDGC: DataGridColumn = new DataGridColumn();
> myDGC.dataField = someField;
> myDGC.headerText = "Some Header Text";
> // ... set more properties as needed
> myColumns.push(myDGC);
> cfgrid.columns = myColumns;
> 
> You can probably find some examples of this on CFlex or other sites.
> 
> HTH,
> Doug
> 
> --- In [email protected], "nasawebguy" <dkerr@> wrote:
> >
> > I have tables in the database that the user can change via a 
> > ColdFusion application, therefore the columns in my Flex DataGrid 
> > need to be dynamic. How do I modify the code below to dynamically 
> > generate the gridcolumns?
> > 
> > Thanks,
> > Don Kerr
> > 
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
> > layout="absolute" creationComplete="initApp()">
> >     
> >     <mx:Script>
> >             <![CDATA[
> >                     import mx.collections.ArrayCollection;
> >                     import mx.rpc.events.ResultEvent;
> >                     
> >                     public function initApp():void
> >                     {
> >                             cfdata.getQuery();
> >                     }
> >                     
> >     public function getQuery_result(event:ResultEvent):void
> >                     {
> >                             cfgrid.dataProvider = event.result 
> as 
> > ArrayCollection;
> >                     }
> >                     
> >             ]]>
> >     </mx:Script>
> >     
> >     <mx:RemoteObject 
> >             id="cfdata" showBusyCursor="true" 
> >             destination="ColdFusion"
> >             source="forms.Simple">
> >             <mx:method name="getQuery" result="getQuery_result
> > (event)" />
> >     </mx:RemoteObject>
> > 
> > 
> >     <mx:Panel label="Simple Grid" width="100%" height="100%" 
> > horizontalCenter="0">
> > 
> > 
> >             <mx:DataGrid editable="true" 
> > alternatingItemColors="[#ece8ff, #ffffff]"  id="cfgrid" 
> width="100%" 
> > height="190" alpha="1.0">
> >                     <mx:columns>
> >                             <mx:DataGridColumn dataField="??" />
> >                     </mx:columns>
> >             </mx:DataGrid>
> >             
> >     </mx:Panel>
> >     
> > </mx:Application>
> >
>


Reply via email to