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