6 Replies Latest reply on Feb 11, 2009 2:39 PM by Newsgroup_User

    Collection Event event.items.length Does Not Match the No. of Items

    alice_data Level 1
      Hi,

      I have been digging around the problem of how to get my CollectionEvent to work, and I seem to be able to see the problem, but I am not sure how to get it to work properly.

      In my example, it works when I try to check or uncheck the check boxes as long as it is the top 2 items of the list, but after that. It never gives me the correct input. I can check the boxes, but the message is never updated accurately.

      Can anyone please help me out?
      Thanks in advance.

      Alice
        • 1. Re: Collection Event event.items.length Does Not Match the No. of Items
          rtalton Level 4
          Have you tried using selectedItems.length? Like:
          trace_txt.text = myDG.selectedItems.length.toString();
          • 2. Re: Collection Event event.items.length Does Not Match the No. of Items
            Level 7

            "alice_data" <webforumsuser@macromedia.com> wrote in message
            news:gmsbjo$ahc$1@forums.macromedia.com...
            > Hi,
            >
            > I have been digging around the problem of how to get my CollectionEvent
            > to
            > work, and I seem to be able to see the problem, but I am not sure how to
            > get it
            > to work properly.
            >
            > In my actionscript, it seems to only tell that event.items.length is 1,
            > while I am calling my array collection from the HTTPService, and I have
            > tested
            > the length of my Array Collection, which seems to be accurate. What I
            > tried to
            > do is to use that number in the CollectionEvent function, but that does
            > not
            > work at all.
            >
            > Can anyone please help me out?
            > Thanks in advance.

            If only one item changed, I'd expect event.items.length to be 1...?


            • 3. Re: Collection Event event.items.length Does Not Match the No. of Items
              alice_data Level 1
              Hi,

              Thanks for Amy's point. I think the question is here how to make it so that every single checkbox can detect which is checked and which is not. Right now, when I check 10 of them, but if I leave any of the first 3 elements unchecked, my total checked result returns 0, but if I check one of the first 3, it brings back the correct number.

              I thought I am using a for loop here, but every time when I try to get getItemAt(i).selected printed out correctly, it always returns me a 0. How come the selected variable changes only when I check on the first 2 check boxes of the array?

              Thanks in advance.

              Alice
              • 4. Re: Collection Event event.items.length Does Not Match the No. of Items
                Level 7

                "alice_data" <webforumsuser@macromedia.com> wrote in message
                news:gmul4e$7eb$1@forums.macromedia.com...
                > Hi,
                >
                > Thanks for Amy's point. I think the question is here how to make it so
                > that
                > every single checkbox can detect which is checked and which is not. Right
                > now,
                > when I check 10 of them, but if I leave any of the first 3 elements
                > unchecked,
                > my total checked result returns 0, but if I check one of the first 3, it
                > brings
                > back the correct number.
                >
                > I thought I am using a for loop here, but every time when I try to get
                > getItemAt(i).selected printed out correctly, it always returns me a 0. How
                > come
                > the selected variable changes only when I check on the first 2 check boxes
                > of
                > the array?

                Could you be a bit more clear on what you're doing here? Do you have check
                boxes repeated with a repeater, or a DataGrid with check boxes as one of the
                itemRenderers? Something else?


                • 5. Collection Event event.items.length Does Not Match the No. of Items
                  alice_data Level 1
                  Hi, Amy:

                  Yes, like you guessed, the code I have provided at the original post is a DataGrid with check boxes as one of the itemRenderers. The checkboxes are checkable, but it seems that it does not change to true when I check them.

                  The only time they work is when I have the ones that are indexed smaller than 1. I hope I am making sense here.

                  Thanks again for your help.
                  • 6. Re: Collection Event event.items.length Does Not Match the No. of Items
                    Level 7

                    "alice_data" <webforumsuser@macromedia.com> wrote in message
                    news:gmveo9$7qh$1@forums.macromedia.com...
                    > Hi, Amy:
                    >
                    > Yes, like you guessed, the code I have provided at the original post is
                    > a
                    > DataGrid with check boxes as one of the itemRenderers. The checkboxes are
                    > checkable, but it seems that it does not change to true when I check them.
                    >
                    > The only time they work is when I have the ones that are indexed smaller
                    > than 1. I hope I am making sense here.

                    Here is some working code you can look at:
                    http://www.returnundefined.com/2007/11/efficient-reusable-and-centered-checkbox-renderers- for-datagrids