2 Replies Latest reply on Oct 31, 2008 11:05 AM by Newsgroup_User

    "Lock" dataProvider when creating Arrays and DataGrids in loop

      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.