![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
I am looping through each item in an Array and for each item, I am trying to
create a new DataGrid on a new Canvas, and then add each Canvas to a ViewStack. I am experiencing difficulty in setting the dataProvider for the DataGrids. As part of the loop, I create a new ArrayCollection to serve as the dataProvider for the last DataGrid created. But since the loop uses just one ArrayCollection variable, everytime the loop iterates and a new ArrayCollection is created, the previously created DataGrids' dataProviders point to the new ArrayCollection, rather than the one that was created during their iteration. For example, I can end up with 10 DataGrids (on 10 Canvases) in the ViewStack, and all of their dataProviders will point to last ArrayCollection created, rather than the ArrayCollection created in the same iteration of the loop that created that respective DataGrid. Is there a way to take a static "snapshot" (for lack of better terms) of an ArrayCollection in each iteration and use that as the dataProvider for the newly created DataGrid in that same iteration? Any help or insight is much appreciated. //Loop through results, add info to DataGrids and DataGrids to ViewStack var canvas:Canvas; var dg ataGrid;var dgArray:ArrayCollection; var dgCols:Array; var dgFieldCol ataGridColumn;var dgValCol ataGridColumn;for each (var result:IdentifyResult in event.identifyResults) { dg = new DataGrid; dg.percentHeight = 100; dg.percentWidth = 100; dgCols = dg.columns; dgFieldCol = new DataGridColumn; dgValCol = new DataGridColumn; dg.showHeaders = false; dg.percentHeight = 100; dg.percentWidth = 100; //dg.addEventListener(ListEvent.ITEM_CLICK,onCellP ress); dgFieldCol.dataField = "field"; dgFieldCol.width = 30; dgValCol.dataField = "val"; dgValCol.width = 70; dgCols.push(dgFieldCol); dgCols.push(dgValCol); dg.columns = dgCols; dgArray = new ArrayCollection; for (var detail:String in result.feature.attributes) { dgArray.addItem({field:detail, val:searchReplace(result.feature.attributes[detail],"Null","")}); } //set up dgArray for datagrid dg.dataProvider = dgArray; //Canvas canvas = new Canvas; canvas.percentHeight = 100; canvas.percentWidth = 100; canvas.addChild(dg); //Add DataGrid canvas to ViewStack idViewStack.addChild(canvas); } |
| Sponsored Links |
|
|||
|
I think I fixed it. Moving var dgArray:ArrayCollection; above dgArray = new ArrayCollection; seems to have done the trick, and makes sense logically.
|
|
|||
|
"Guddie" <webforumsuser@macromedia.com> wrote in message news:gefgau$8ep$1@forums.macromedia.com... >I think I fixed it. Moving var dgArray:ArrayCollection; above dgArray = new >ArrayCollection; seems to have done the trick, and makes sense logically. Might I suggest that you look at my GroupingFunction calendar example to see one way that you can have a control (in my case a TileList) that _appears_ like there are a lot of them being switched between with a TabBar, but what's actually happening is the dataProvider is simply being filtered in a different way: http://flexdiary.blogspot.com/2008/0...featuring.html |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise
| Right Column Title |