This content has been marked as final. Show 4 replies
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.
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.
That should be fine.
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.