Notes on Java, Solaris, PHP, LDAP…

November 17, 2007

Parameterized renderers in Adobe Flex MXML

Filed under: Uncategorized — negev @ 8:05 pm

4 April 2007

Parameterized renderers – re-using a renderer for several columns
Below is how to parameterize renderers. Then you can reuse a renderer for several columns. It’s useful when you need to highlight/render the whole row in same way, depending on its data. Note the curly brackets {}:
<mx:DataGridColumn dataField=”fullname” headerText=”Full Name” itemRenderer=”{new utils.MemberRendererFactory(‘fullname’)}” />

In MemberRenderer.mxml:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Text xmlns:mx=”;
text=”{data[field]}” styleName=”{data.is_admin ? ‘adminStyle’ : ” }” >
public var field: String= “default-field-here”;

In utils/
we render a fields specially if the data row has ‘is_admin’ field set

package utils
import mx.core.IFactory;

public final class MemberRendererFactory implements IFactory
private var field: String;

public function MemberRendererFactory( givenField: String ) {
field= givenField;

public function newInstance(): *
var renderer:MemberRenderer = new MemberRenderer();
renderer.field= field;
return renderer;


A single-column renderer
<mx:DataGridColumn width=”27″ dataField=”my_field” headerText=”Some header” itemRenderer=”MemberStarRenderer” />


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: