6 Replies Latest reply on Apr 1, 2011 2:06 AM by Benoitcn

    Different between DataGroup and List

    Benoitcn Level 1

      I create one custom layout.When the use different parent container. The result is different.

      when I use list with my layout. There is always an error occured at

             for(var i:int = 0; i< childsCount; i++)
                     {
                          //get the current element
                          //
                          //the currentElment always null when use List
                          //when use DataGroup everything works fine !!
                          var currentElement:ILayoutElement = targetContainer.getElementAt(i);
                          
                          currentElement.setLayoutBoundsSize(NaN,NaN);
                          
                          currentElement.setLayoutBoundsPosition(arr[i].x-20, arr[i].y+30);
                     }
      
      
      

       

       

      The other question is use the sane blendMode to the DataGroup and List component has different result.

        • 1. Re: Different between DataGroup and List
          Shongrunden Adobe Employee

          If you set useVirtualLayout="false" on the List does it act the same as the DataGroup?

          • 2. Re: Different between DataGroup and List
            Benoitcn Level 1

            No I don't open the useVirtualLayout when I used the List component. But I find the DataGroup do not have "useVirtualLayout" property.

            But in my first post I use getElement not getVirtualElement. So how can I get each Element from DataGroup.

            And why I can't use getElement get element from a list disabled useVirtualLayout property.

             

            This is all my mxml code:

             

                 <s:DataGroup id="menu" dataProvider="{array}" itemRenderer="com.layout.renderer.ListItem" 
                                 right="0" left="0" top="5" bottom="200" cacheAsBitmap="true" blendMode="overlay">
                      <s:layout>
                           <layout:CircleLayout clipAndEnableScrolling="true" />
                           <!--<layout:LargeCircleLayout />-->
                      </s:layout>
                 </s:DataGroup>
            

            • 3. Re: Different between DataGroup and List
              Shongrunden Adobe Employee

              If I'm understanding correctly you have a layout that works in a DataGroup, but does not work in a List.

               

              I suspect that this is because the DataGroup component does not use virtual layout by default, but the List component does.

               

              To confirm that is the case try using a DataGroup with your layout and set useVirtualLayout to true on that layout:

              <s:DataGroup id="menu" dataProvider="{array}" itemRenderer="com.layout.renderer.ListItem"

                                   right="0" left="0" top="5" bottom="200" cacheAsBitmap="true" blendMode="overlay">

                 <s:layout>

                      <layout:CircleLayout clipAndEnableScrolling="true" useVirtualLayout="true" />

                 </s:layout>

              </s:DataGroup>

               

              If that does fail then you know that virtual layout is the issue.

               

              If you don't need virtual layout then you can turn it off by setting useVirtualLayout="false" directly on the List (notice that is different than how you toggle useVirtualLayout on a DataGroup where the property is on the layout).

               

              If you do need virtual layout then you might find this post useful for learning how to make your custom layout support virtual layout: http://flexponential.com/2010/03/06/learn-how-to-create-a-simple-virtual-layout-in-flex-4/

               

              • 4. Re: Different between DataGroup and List
                Benoitcn Level 1

                Thanks very much.

                The property of useVirtualElelment is the real problem.

                When I disabled it. The List component works fine with my layout.

                So I think I should adjust my layout to adept two conditions.

                 

                But I find this from the as3.0 language documents, from here

                "The DataGroup class is the base container class for data items. The DataGroup class converts data items to visual elements for display. While this container can hold visual elements, it is often used only to hold data items as children."

                According to the document the DataGroup always convert item to virtual elements for display.

                I have a question how can the DataGroup returns elements by using "getElement" function ?

                • 5. Re: Different between DataGroup and List
                  Shongrunden Adobe Employee

                  I think you are confusing "visual" and "virtual".

                   

                  DataGroup takes data items from its dataProvider property and renders them as visual elements by creating ItemRenderer instances.  Non-virtual layout creates a renderer for every item even those that aren't in view which can cause long startup times when you have hundreds or thousands of data items in your list.  Virtual layout is an optimization that only creates enough renderers to show the items that are actually in view at one time.

                  • 6. Re: Different between DataGroup and List
                    Benoitcn Level 1

                    Yes, I maked mistake when reading the documents.

                    Thank you very much to point out that.