To specify an item renderer for a component like an AdvancedDataGridColumn, all you need to do is provide the full package and class name in the MXML tag:

<mx:AdvancedDataGridColumn id="column"
    itemRenderer="" />

However if you want to specify different renderers based on a conditional state, like when a component is enabled or editable, it’s not exactly as straightforward.

Similar to specifying a percentage width in MXML, specifying a string for an item renderer doesn’t work when you use data binding. Instead of strings, you have to specify IFactory instances.

Here’s how to do it:

<mx:AdvancedDataGridColumn id="column"
    itemRenderer="{column.editable ?
    new ClassFactory (CustomEditableItemRenderer) :
    new ClassFactory (CustomItemRenderer)}" />

This approach also has the benefit of providing an implicit state. In the above example, the item renderers would know if the column is currently editable, whereas normally they would only have access to the particular row of data to be rendered.

About these ads