3 Replies Latest reply on Feb 5, 2009 3:31 PM by Newsgroup_User

    Object Oriented Programming/Collection Binding Question

    ericbelair Level 1
      I have a Collection, and I want to remove all items that have a certain property set to true. I use a filterFunction to accomplish this. My question is, how can I add new items to the Collection that have that property set to true? The filterFunction is still applied, and the item is not added....

      Do I have to iterate through the entire collection and remove items one at a time? I thought that that is exactly what refresh() does.

      Thanks.
        • 1. Re: Object Oriented Programming/Collection Binding Question
          Level 7

          "ericbelair" <webforumsuser@macromedia.com> wrote in message
          news:gmd1qj$9if$1@forums.macromedia.com...
          >I have a Collection, and I want to remove all items that have a certain
          > property set to true. I use a filterFunction to accomplish this. My
          > question
          > is, how can I add new items to the Collection that have that property set
          > to
          > true? The filterFunction is still applied, and the item is not added....

          Absolutely it IS added...you just don't see it, because it's been filtered.
          Just like when you filter an excel spreadsheet--those records aren't gone,
          just hidden.

          > Do I have to iterate through the entire collection and remove items one at
          > a
          > time? I thought that that is exactly what refresh() does.

          Change your filterFunction to look for some other property that tells you
          this is a new object.


          • 2. Object Oriented Programming/Collection Binding Question
            John Hall Level 4
            It took me a minute to understand Amy's suggestion but of course it makes sense. If you're setting isSpecial to false, the evaluation of the filterFunction will be false for normal items (i.e., false to the directive to return the object). Amy's generally right on but sometimes she causes me to have to stop and think. I hate that; it's too time-consuming.
            • 3. Re: Object Oriented Programming/Collection Binding Question
              Level 7

              "John Hall" <webforumsuser@macromedia.com> wrote in message
              news:gmfa05$5qf$1@forums.macromedia.com...
              > It took me a minute to understand Amy's suggestion but of course it makes
              > sense. If you're setting isSpecial to false, the evaulation of the
              > filterFunction will be false for normal items (i.e., false to the
              > directive to
              > return the object). Amy's generally right on but sometimes she causes me
              > to
              > have to stop and think. I hate that; it's too time-consuming.
              >

              There's a little scale in my head, with your time on one side and mine on
              the other ;-).