5 Replies Latest reply on Dec 3, 2009 8:06 AM by UbuntuPenguin

    List-like behaviour without item renderer

    UbuntuPenguin Level 4

      Hello Everyone ,

        I have 4 or 5 VBoxes.  I would like to use them in a list like fashion , (selectable , highlighting ) but I dont want to use an itemrenderer because of all that it entails ( recycling itemrenders , .... ).  Is there anyway I can organize flex containers and use them as a list without having to use a custom itemrenderer ?

       

      Sincerely ,

        Justin Dallas

        • 1. Re: List-like behaviour without item renderer
          flex2008 Level 3

          you can make use of repeaters.

           

          <mx:VBox>
              <mx:Repeater dataProvider="{dp}" id='rptr'>
                  <mx:Label text="{rptr.currentItem.label}"/>
              </mx:Repeater>
          </mx:VBox>

          • 2. Re: List-like behaviour without item renderer
            danny_run Level 1

            You can also add them from actionscript:

            for each(var y:YourOBject in YourObjectList){
                                var custom:YourCustomHbox=new YourCustomHbox();
                                custom.yourObject=y;//the hbox is populated with your object
                                addChild(custom);//adds the hbox in the parent screen.
                            }  

            You just need to create a new component which extends Hbox (for example) in which you create the fields that you want and populate them.

            • 3. Re: List-like behaviour without item renderer
              UbuntuPenguin Level 4

              Thanks fellas.  The only problem with employing a repeater is that I lose the list-selectability / highlighting aspect.

               

              Sincerely ,

                UP

              • 4. Re: List-like behaviour without item renderer
                paul.williams Level 4

                What's the problem with using List?

                • 5. Re: List-like behaviour without item renderer
                  UbuntuPenguin Level 4

                  Hey Paul ,

                    Okay , here is the main problem.  In my app , I will have many objects ordered in the form of lists/vboxes.  These objects will have interconnections , basically a line sprite drawn across the canvas from one to the other.  The objects have data deciding who is connected to whom.

                    In the case of the list , I would have to use an itemrenderer , <mx:HBox> ... </mx:HBox>.  Now here is the question , knowing object A connects to object B , how would I find the itemrenderers of A  and B , and retrieve x,y coordinates for both to draw the line.  Not to mention , I'm not sure if a list recycles item renderers on dataprovider updates which could lead to "ghost" lines.

                    In the case of a vbox filled with containers that are contain the object data , I can have concrete x and y guaranteed not to change.  However , I lose the list functionality.  Now that I think about it , I may just hack an itemrenderer and keep the list.

                   

                  Sincerely ,

                    UP