2 Replies Latest reply on Feb 4, 2009 11:19 AM by Newsgroup_User

    Counting items after filterfunction

    deuce4
      Is it possible to count the number of items in an ArrayCollection that called out by a filterfunction?

      I wonder....?
        • 1. Re:  Counting items after filterfunction
          JeffryHouser Level 4

          I'm not sure if you want the number of items left in the ArrayCollection after the filter or the number of items removed from the ArrayCollection by the filter.

          For the former, AC.length should do it.

          For the latter, I don't know of a way. But you could easily save the length before filtering, and do some math after filtering to find the number.
          • 2. Re: Counting items after filterfunction
            Level 7

            "JeffHouser" <webforumsuser@macromedia.com> wrote in message
            news:gmc8hd$8sn$1@forums.macromedia.com...
            > I'm not sure if you want the number of items left in the ArrayCollection
            > after the filter or the number of items removed from the ArrayCollection
            > by the
            > filter.
            >
            > For the former, AC.length should do it.
            >
            > For the latter, I don't know of a way. But you could easily save the
            > length
            > before filtering, and do some math after filtering to find the number.

            The source length will not change, and the ArrayCollection length will.

            So,

            var numFilteredItems = AC.source.length - AC.length;

            HTH;


            Amy