Reputation: 9575
I'm using a custom item renderer in my datagrid, and need to make a button visible or invisible based on if there has been a negative value on any of the values in the renderer. So I'd like to set a flag to false when the first renderer is set off, turn it to true if there's any negative values, and at the end check for the value of the flag. I know I can dispatch a dataChange event for every time the data is changed in the renderer instances, but I was wondering if there is anyway I can know when all of them are done? Thanks!
Upvotes: 1
Views: 253
Reputation: 891
You should have a look into RendererExistenceEvents. You should be able to tell when they are all created based on how many items you have in your list or at least how many should be in view at once.
Upvotes: 1
Reputation: 18193
There is no such event.
Like any other Flex component, a renderer will dispatch a CREATION_COMPLETE
after it's been created. ItemRenderers
are generally recycled (the same object gets assigned new data to render), thus listening for CREATION_COMPLETE
is not sufficient, unless you disable the recycling.
For a Spark List
component, you can disable recycling by setting useVirtualLayout=false
on the layout class. I'm not sure if the Spark DataGrid
class support this or not. The MX DataGrid may have some other way to do this.
Disabling the recycling, however, can have performance implications. I think your idea w/the DATA_CHANGE
event is the best solution:
data
property) to know when the data has changedUpvotes: 2