4 Replies Latest reply on May 20, 2008 12:09 AM by Sergejack

    first item of itemrenderer created twice?

    alexales
      I have a datagrid with an itemrenderer witch for every item created it adds an event listener to the parentdocument.But the first item(as sorted from the datagrid) always has two listeners so the handler insideot runs twice.anyone know What's is wrong?
        • 1. Re: first item of itemrenderer created twice?
          peterent Level 2
          Flex itemRenderers are only created for the visible rows of a list control, plus one or two extra for recycle buffering. The itemRenderers are recycled as the user scrolls the list. For example, if you have 1000 items but only 10 rows visible, then only 11 or 12 itemRenderers are created. At first they show records 1-10. As the user scrolls, the data for record 1 scrolls out of view, but the itemRenderer that was showing that data is moved to the bottom of the list area and is given the data for row 11. The itemRenderers for records 2-10 are shifted upward.

          Sorting the list simply causes the itemRenderers to receive new data - they generally do get moved to new locations as the result of a sort of a filter.

          If you add event listeners on the parentDocument you may be getting very confused and mismatched data and events as the list is scrolled.
          • 2. Re: first item of itemrenderer created twice?
            alexales Level 1
            Is there a way to overcome this and control the data in the itemrednerers even if they are not visible?
            • 3. Re: first item of itemrenderer created twice?
              peterent Level 2
              I can see no way to do this. Why do you want to add en event listener to the parent document? Perhaps there is another way to approach the problem you are trying to solve.
              • 4. Re: first item of itemrenderer created twice?
                Sergejack
                If you force the whole number of lines in the datagrig to be displayed (by setting an appropriate height to the datagrid), I tihnk you can force every itemRenderers'creation just once.