简体   繁体   中英

Call a method of a child of a datagroup

I'm looking for a way to call a method for ALL children elements of a DataGroup from the DataGroup. The problem is that when using the creationComplete event to call a method of a child that method is only called once for every itemrenderer (child) object. after the item was drawn once.

now i want the children component to call a function everytime the datagroup containing it changes its data. Using "updateComplete" or "dataChange" inside the children (itemrenderer) component would work, BUT "updateComplete" and "dataChange" is called everytime i change the view (eg scroll my list) - thats not what i want.

//edit i also tried getting the children by going trough the parent.dataprovider array and the parent.getchild array with no luck, it sais that the elements are null but when i check in debug mode they are not. however, there has to be a easier way anyway.

It sounds like you have a misunderstanding of how the DataGroup works.

The DataGroup accepts a dataProvider property; and that dataProvider will implement the iList interface. Common dataProviders might be an ArrayCollection or an XMLListCollection.

For the sake of this explanation, let's assume that there are 100 items in the dataProvider.

The DataGroup is going to look at how much visual space it has to display items; and create that many instances of an itemRenderer. For the same of this explanation, let's say there are 7 elements displayed in the DataGroup.

So, in this situation, the DataGroup has seven children even though the dataProvider has 100 elements in it.

As you scroll through the dataGroup, each renderer is reused. The DataGroup never has more than seven children.

The DataGroup does not have a data property, so running code against the DataGroup whenever the data changes is a bit confusing. You should be able to run code everytime the DataGroup's dataProvider changes, either by extending and overriding the set dataProvider method or by adding an event handler to the dataProviderChanged event. All bindable properties fire a similarly named event even though they aren't explicitly documented.

Does this help? If not, perhaps you need to tell us what you want to do in more specific terms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM