4 Replies Latest reply on Jun 25, 2008 1:03 PM by Dtancredi

    Accessing Repeater -> VBOX -> list elements


      I'm wondering how to access + clear a list (selected = -1?) that's nested within a VBOX and that's nested in a Repeater. Basically, I'm creating two level nav, that has a list using the second level, and VBOX's on the first level.

      Whenever I select one of the list elements, it calls the function "updateItem(e:Event)" which updates a value that other components are bound to... But I need to clear the other list elements somehow, and was thinking of calling a function within that function "clearLists()" but need to figure out how to access those lists.

      Any ideas?
        • 1. Re: Accessing Repeater -> VBOX -> list elements
          ntsiii Level 3
          If you give an element in a repeater an id, you can access repeated instances of that element using array notation:
          myId[n], where "n" is it index of the dataPrvoider item.

          For complex repeated content, I advise creating a custom component with all of the controls in it and repeat that. Pass in the entire currentItem. I've posted example code several time, try seraching for it if you want.

          • 2. Re: Accessing Repeater -> VBOX -> list elements
            Dtancredi Level 1
            Thanks Tracy!

            I searched your posts, and abstracted my mxml into a separate component under the repeater, passing that component the currentItem of the repeated object. So that's good!

            My trouble is that I'm using Cairngorm, and trying to figure out the best practices approach to clearing the selectedIndex for all the lists contained in the component, by updating the model that these repeated components are binding to. Maybe I'm overthinking this.

            The hierarchy is VAccordion, which contains a Repeater of a component (vbox-list). I'm using Repeater because the data is pulled dynamically from a database. If I click on one of the Vaccordion headers, it shows me the component, and I can select a listItem. However, if I click on a different header (showing me a different component - which works fine), and click back, the listItem is still selected (which of course it would be, since the lists aren't bound in any way, so wouldn't detect a "change" event).

            What I'm looking to do is to call a "clearLists" method to change the selectedIndex of all the lists to -1 and THEN set the selectedList index to equal the modelLocator.currentList. The second part, I can do, it's the first part that's difficult... I can't access the repeater component in the Command I'm using...but I CAN access the modelLocator. So I'm thinking, when I create the component, to bind the lists to a state in the modelLocator?

            I'm not sure what's best here, but appreciate your advice.

            • 3. Re: Accessing Repeater -> VBOX -> list elements
              ntsiii Level 3
              That should be fine.
              • 4. Re: Accessing Repeater -> VBOX -> list elements
                Dtancredi Level 1
                I figured it out!
                First, in my modelLocator (model) I made sure all my xml data was put into an ArrayCollection of Value Objects (each of which also had an array collection of value objects - like a hashed array). Then I created a Value object for the selectedCampaign in the model.

                Then I did this in the list component:
                change="modelLocator.selectedCampaign = event.target.selectedItem" />

                So the multiple lists will each check if that VO is in their list and if it isn't, show up as deselected! Go Cairngorm!

                Here's the link that helped me unravel that:

                Thanks again, Tracy. Hope that helps someone.