variable scope for DataGrid
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
[Bindable]
public var localVar:String="application variable";
[Bindable]
private var myData:ArrayCollection = new ArrayCollection([
{ Artist:'A', Album:'aa',Price:1.9, Cover:'a.jpg'},
{ Artist:'B', Album:'aa',Price:1.9, Cover:'b.jpg'}
]);
</mx:Script>
<mx:DataGrid id="myGrid" dataProvider="{myData}" width="100%" variableRowHeight="true">
<mx:columns>
<mx:DataGridColumn dataField="Cover">
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:Script>
[Bindable]
public var localVar:String="Renderer variable";
</mx:Script>
<mx:Text id="albumName" width="100%" selectable="false" text="{data.Album}"/>
<mx:Image id="albumImage" height="45" source="{data.Cover}"/>
<mx:TextArea text="{'Renderer localVar= ' + localVar}"/>
<mx:TextArea text="{'Application localVar= ' + outerDocument.localVar}"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>
Related examples in the same category