1 Reply Latest reply on Mar 1, 2011 9:06 PM by Shongrunden

    Loading controls in Datagroup

    Flex Rock Level 1


              I have a Datagroup  in which i have an ItemRenderer of  Label and HRule. The length of dataprovider is  4. So label and Hrule appears four times. But i need the Hrule to be  appeared only three times.




      I need the layout to be like this.





        • 1. Re: Loading controls in Datagroup
          Shongrunden Adobe Employee

          You can use the itemIndex property of ItemRenderer and compare it against the length of the DataGroup's dataProvider.


          Here is a simple example:

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"



              <s:DataGroup width="100">


                      <s:VerticalLayout gap="0" horizontalAlign="justify" />















                                      import spark.components.DataGroup;


                                      override public function set data(value:Object):void {

                                          super.data = value;

                                          if (!data)



                                          // set the Label text

                                          lbl.text = data as String;


                                          // find the number of items in the dataProvider

                                          var d:DataGroup = owner as DataGroup;

                                          var numItems:int = d.dataProvider.length;


                                          // only show the separator if its not the last item

                                          if (itemIndex == numItems - 1){

                                              separator.visible = false;

                                          } else {

                                              separator.visible = true;





                              <s:Label id="lbl" />

                              <s:Rect id="separator" width="100%" height="1" bottom="0">


                                      <s:SolidColor color="black" />