1 Reply Latest reply on Jun 16, 2010 9:42 PM by Shongrunden

    Getting data out of DataGroup


      I have this DataGroup which is rendered with a class called Authors:


      <s:DataGroup id="author_info" itemRenderer="Authors" dataProvider="{auth}" includeIn="authors">


      Data from auth goes into the renderer with no problems. But when I try to get data out of each instance of Authors (few text boxes) there is probelm. I have no idea how to reference each child in the DataGroup. I have been banging my head for the past 48 hours but I cannot extract data from each item in the DataGroup. I have even tried setting off custom Events from inside the Authors when those text boxes change hoping it would be cought by author_info so I could access it but I just cant . Help me.....

        • 1. Re: Getting data out of DataGroup
          Shongrunden Adobe Employee


          In general when dealing with a DataGroup you should only interact with it via its data items and rarely need to access the instances of the ItemRenderers directly.  If the user changes something inside the ItemRenderer, then that renderer should save that information back to its data item.


          If you do want access to the renderer instances directly then you can use the getElementAt() method.  But, be careful when using this method with a List or in a DataGroup with a layout that has useVirtualLayout="true".  In those cases you should be fully aware of the consequences of virtual layout before relying on this method.



          There are times when you will want to fire events from an ItemRenderer to its parent DataGroup.  In this case I find it useful to dispatch the event on the ItemRenderer's owner property, for example:

          <s:ItemRenderer ... click="sendEvent()">



                import spark.components.DataGroup;


                private function sendEvent():void {

                  (owner as DataGroup).dispatchEvent(new MyCustomEvent());