2 Replies Latest reply on Jul 9, 2009 12:57 AM by flx23

    List item renderer insert new item

    flx23 Level 1



      i have assigned an array to the dataprovider of list..and further i have a itemrenderer...Three fields are coming from DB table

      under item renderer i have taken an image...now as i run the app..i see the n number of images depending upon the array items..if 10 items are in array that i have binded with the list then i am getting 10 images..as i have just placed image under item renderer thats why..



      Now my question is to insert two images in the item renderer one at the top and other at the bottom

      if 10 images are being displayed then i want to insert one on the first position and second at the last position


      Note:--image is of drawer that i am repeating..i want the upper part and the lower part of the cabinet to be inserted after all the drawers have been created

      so if i scroll the list all should scroll



        • 1. Re: List item renderer insert new item
          *Prashant Shelke* Level 4

          If u want to add itemrendrers indirectly u need to insert to Objects in the dataProvider.

          var object:Object = new Object();

          object.imagePath = "spcify here image path..."; // this object can be anything in u r case.

          dataProvider.addItemAt(object, 0); // 1st position


          object = new Object();

          object.imagePath = "spcify here image path...";

          dataProvider.addItemAt(object, dataProvider.length - 1); // last position

          • 2. Re: List item renderer insert new item
            flx23 Level 1

            this is my code





            list_grid.dataProvider=_data;  // list_grid is the list control to whom i am binding data




                 main page




            <mx:List  paddingLeft="0"    paddingBottom="0" paddingTop="0" width="100%" backgroundColor="#fffde8" id="list_grid" height="390"  borderStyle="none"  itemRenderer="itrRenderer"   selectionColor="#71aef9"    />


            itemrednrer page


            <mx:Canvas creationComplete="init()"  borderStyle="none" top="0" left="0" bottom="0" horizontalScrollPolicy="off" verticalScrollPolicy="off" xmlns:mx="http://www.adobe.com/2006/mxml" width="383" textAlign="left" height="40">


            <mx:Image top="0" bottom="0"  id="imgSelected" source="@Embed(source='../../Assets/drawer_img.png')" maintainAspectRatio="true" x="0" width="383"/>




            now you are saying this


                                         var object:Object = new Object();
                                       object.imagePath = "top_img.png";
                                      dataProvider.addItemAt(object, 0);




            where to insert this code...


            what it means indirectly creating itemrendrer please explain