Search code examples
apache-flexdatagridscopeactionscript-2itemrenderer

flex itemRenderer variables from/to main scope


I'm working on creating a datagrid that has a checkbox column. I have some functions that run within the itemRenderer that creates an array collection containing the item information and weather or not the checkbox is checked or not.

Everything seems to be work the way I'd like, but now I just need to access the arraycollection created in the itemRenderer scope in my main application. How can I go about access this?

Here's the function that creates the AC within the itemRenderer

private function onChange():void {
      data["isSelected"] = cb.selected;
        var dp:ArrayCollection = _dataGrid.dataProvider as ArrayCollection;
        dp.dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE));               
    }

Solution

  • I second the approach letting a dedicated event bubble through the DataGrid towards the controller. This lets you create loosely coupled components and is easy to implement as well.