4 Replies Latest reply on Feb 16, 2011 4:34 AM by _spoboyle

    List itemRenderer being reused

    _spoboyle Level 4

      I have a list with a custom itemRenderer. when the dataprovider for my list is updated under certain conditions some of the items do not render the correct data.

       

      this seems to be due to Flex trying to reuse old itemRenderer instances without updating the itemRenderer's data property.

       

      Is this a known issue? Is there a way to ensure that the itemRenderers aren't reused or that the itemRenderers data property is updated?

       

      (All the data is stored in a database and if i quit and relaunch the application the data displays correctly)

        • 1. Re: List itemRenderer being reused
          oldMster Level 3

          Did include the [Bindable] clause on your dataprovider declaration?

           

          If so, and it is still missing the update event, I believe most of the list classes have an 'invalidateXXX' method you can call when your data is updated.  This forces the list to refresh it's data from the dataprovider

          • 2. Re: List itemRenderer being reused
            Flex harUI Adobe Employee

            For MX List, the renderers must handle recycling properly.  See the first

            item renderer post on my blog.

             

            For Spark List, you can set useVirtualLayout=false

             

            --

            Alex Harui

            Flex SDK Team

            Adobe System, Inc.

            http://blogs.adobe.com/aharui

            • 3. Re: List itemRenderer being reused
              _spoboyle Level 4

              Yes the dataprovider is bindable and yes I am getting the update event, that's not the issue.

               

              basically my datgroup displays some calendar entries (an ordered arrayCollection) so we might have a datagroup displaying entries for

               

              3rd Feb -- text1

              4th Feb -- text2

               

              now if i add a new entry to this list for 2nd Feb with text3 i get the following result

               

              3rdFeb -- text3

              4rdFeb -- text1

              4thFeb -- text2

               

              the first 2 itemRenderer instances are reused without updatign the correct date value however the correct text is used

              a new itemRenderer instance is created and populated with the data from the last item in the list

              • 4. Re: DataGroup itemRenderer being reused
                _spoboyle Level 4

                sorry my project is quite complicated for someone that has only been working with Flex for a month, it's not the List but the a Datagroups that are causeing the issue.

                 

                I actually have a list in a datagroup in a datagroup and both datagroups have the same problem.

                 

                I have tried using useVirtualLayout on the DataGroups it does not solve the issue