Skip to content

Instantly share code, notes, and snippets.

@ThomasBurleson
Created March 28, 2011 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasBurleson/891377 to your computer and use it in GitHub Desktop.
Save ThomasBurleson/891377 to your computer and use it in GitHub Desktop.
Flex ItemRenderers - global data usages
<?xml version="1.0" encoding="utf-8"?>
<mx:DataGrid width="100%" height="100%"
xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
/**
* Array of localized, marker labels
*/
public var availableMarkers : Array = [ ];
/**
* Utility method used by each itemRenderer instance;
* obviates need to inject markers INTO each instance.
*
* @param j GroupID used as index into string array
* @return String Marker label for the specified groupID
*/
public function lookupMarker(j:uint):String {
return (j < availableMarkers.length) ? String(availableMarkers[j]) : "";
}
]]>
</mx:Script>
<mx:columns>
<mx:DataGridColumn width="55" headerText="Marker">
<mx:itemRenderer>
<mx:Component>
<mx:Label text="{ outerDocument.lookupMarker(data.groupId) }" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment