Accessing Flex DataGrid ItemRenderers
I had an example recently of two DataGrids with custom itemRenderers. In a particular scenario when an item was clicked in grid one I needed to clear all checked values in a particular rowIndex in grid two. There is more than one way to skin a cat I know but my particular situation required the clearing to be performed within the custom itemRenderer itself using a method I defined named clear(). If you were to try and access a custom itemRenderer your gonna have problems casting the renderer to your custom renderer probably with an error like:
Error #1034: Type Coercion failed: cannot convert mx.core::ContextualClassFactory to …your custom renderer
Paranoidferret comes up with a quick solution to accessing the itemRenderers via an array retrieved through a simple getter in a custom grid that retrieves the DataGrids listItems. A quick look into the ListBase class shows that listItems are an array of rows that are arrays of columns.
So with this in mind I could now access the corresponding row itemRenderer and call the clear() method using something such as:
As always I would appreciate hearing any better alternative suggestions.