When I attempt to create a small number of DataGrid controls with a
Repeater, I get the following compile error message:

Unable to generate initialization code within Repeater, due to id or
data binding on a component that is not a visual child.

Here is the minimal amount of MXML that generates the compile error:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
     layout="absolute">
     <mx:ArrayCollection id="myAC"/>
     <mx:ArrayCollection id="headersAC" source="{headers.header}"/>
     <mx:Model id="headers">
         <headers>
             <header>Header 1</header>
             <header>Header 2</header>
             <header>Header 3</header>
             <header>Header 4</header>
         </headers>
     </mx:Model>
     <mx:VBox>
         <mx:HBox>
             <mx:Repeater id="repeater1" dataProvider="{headersAC}">
                 <mx:DataGrid id="datagrid1" width="125" height="210"
                     dataProvider="{myAC}">
                     <mx:columns>
                         <mx:DataGridColumn
                            
headerText="{repeater1.currentItem.header}"/>
                     </mx:columns>
                 </mx:DataGrid>
             </mx:Repeater>
         </mx:HBox>
     </mx:VBox>
</mx:Application>

There is a claim of a workaround at Nischal's blog: Referencing
components inside the mx:Repeater <http://blog.nischal.com/?p=29> , but
there is no source code to show how to do this.

Any ideas on the workaround for this problem?



Reply via email to