Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Thread Tools Rate Thread Display Modes
Old 02-13-2009, 12:46 PM   #1
Alice the Newbie
Join Date: Jan 2009
Posts: 128
Default Problem Populating and Creating a Dynamic DataGrid


After fiddling around with the code, I have edited my code what has been attached. However, the Alert.show boxes get populated correctly, and yet no new data column has been added.

ActionScript Code:
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="simulation.send()"> <mx:Script> <![CDATA[     import mx.controls.dataGridClasses.DataGridColumn;      import mx.controls.*;      import mx.controls.DataGrid;      import mx.rpc.events.ResultEvent;      import mx.events.*;      import mx.collections.*;      [Bindable]private var selArr2:Array;      [Bindable]private var selArr3:Array;      [Bindable]private var selArr_num:int;      [Bindable]private var selArr2_num:int;      [Bindable]private var prods:ArrayCollection = new ArrayCollection();      [Bindable]private var prods2:ArrayCollection = new ArrayCollection();      [Bindable]private var len2:int;      [Bindable]private var message2:String;      [Bindable]private var message3:String;      [Bindable]private var region_name:String;      [Bindable]private var population:String;      [Bindable]private var market:String;      [Bindable]private var myDataGrid:DataGridColumn;            private function result(event:ResultEvent): void{         prods2= event.result.time_log.region_id.location;      }      private function checkBox_change(evt:Event,x:Array):void{         selArr2= [];         var idx:int;         len= prods2.length;        for (idx=0;idx<len2;idx++) {          if (x[idx].selected) {                        selArr2.push(x[idx].data);           }        }          selArr2_num= selArr2.length;          message2= selArr2.join("\n");          cartItems_text();          select_array();     }   private function cartItems_text():void{         selArr3= [];         var idx:int;         var idx2:int;        for (idx=0;idx<selArr_num;idx++) {                         for (idx2=0;idx2<selArr2_num;idx2++) {           selArr3.push(selArr2[idx2].toString());             }        }             message3= selArr3.join("\n");              cartItems.text="";         cartItems.text += message3+ "\n";     }   private function select_array():void{          var myDataGrid:DataGrid = new DataGrid();      var columns:Array = [];       for (var i:int=0;i<selArr3.length;i++) {             var test:String= selArr3[i];             var test2:Array= test.split("|");             region_name= test2[0];             var myDataGridColumn:DataGridColumn = new DataGridColumn();                 myDataGridColumn.headerText = "Region Name";                 myDataGridColumn.dataField = region_name;                 Alert.show("This is interesting2");                 columns.push(myDataGridColumn);                                 population= test2[1];                 myDataGridColumn = new DataGridColumn();                 myDataGridColumn.headerText = "Population";                 myDataGridColumn.dataField = population;                 Alert.show("This is interesting");                 columns.push(myDataGridColumn);                                         market= test2[2];                                       trace ("Region Name: " + test2[0]);             trace("Population: " + test2[1]);             trace("Market: " + test2[2]);                    }           myDataGrid.columns = columns;   } ]]> </mx:Script> <mx:HTTPService id="simulation" result="result(event)" useProxy="false" url=""/> <mx:Panel title="Check Box Control Example" height="75%" width="75%" layout="horizontal" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"> <mx:Canvas id="region_info" width="185" y="34.95" label="Region"> <mx:VBox> <mx:Repeater id="checkBoxRepeater2" dataProvider="{prods2}">  <mx:CheckBox id="checkBox2" label="{checkBoxRepeater2.currentItem.name}"        data="{checkBoxRepeater2.currentItem.name} |{checkBoxRepeater2.currentItem.population}|{checkBoxRepeater2.currentItem.market}"       change="checkBox_change(event,checkBox2)"/> </mx:Repeater> </mx:VBox> </mx:Canvas> <mx:VBox id="vbox1">  <mx:Label text="Selections"/> <mx:TextArea id="cartItems" width="800" height="150"/> </mx:VBox> </mx:Panel> </mx:Application>

Looks like the result has been output correctly in the console with the trace function, but what I would like is to have it displayed on the DataGrid. Can anyone please give me a few pointers on this?

Thanks in advance.
ajwei810192 is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
popup datagrid not populating data from xml jgoods Components 6 05-09-2008 05:59 PM
[AS3] Dynamic Datagrid In Accordian Menu J_Buda Components 0 06-11-2007 08:48 AM
Creating My Own DataProvider Property to an DataGrid AkiraX Components 1 07-31-2006 02:36 PM
dynamically creating text fields and populating with data dolby411 ActionScript 2.0 6 08-30-2004 04:00 PM

All times are GMT. The time now is 09:03 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.