jhinkley
jhinkley

Reputation: 668

Refresh existing DataGrid ItemRenderers

I have an advancedDataGrid with a custom itemRenderer and a radio button group outside of the grid. When selecting the radio buttons, i need to update the display state of the itemrenderers. I'm using a classfactory with the properties attribute to pass in the parameter to the renderers.

When adding a new row to the grid, the itemrenderer appears with the correct display state, but any renderers that are already on the screen when i change the radio button do not refresh their display. I've tried calling refresh() on the dataprovider, invalidateList() and invalidateDisplayList() on the datagrid, setting the dataprovider to null and then resetting it, setting the itemrenderer property on the column to null and then resetting it....nothing forces the renderer to update.

The grid is in a tabNavigator so if i change the tab and then come back, the renderers all get redrawn, but this is not an acceptable workaround. How to you tell the grid to destroy all of its current renderers and re-create them?

Upvotes: 2

Views: 1391

Answers (1)

jhinkley
jhinkley

Reputation: 668

Figured it out. Here is simplified version.

<mx:AdvancedDataGrid 
    id="myDatagrid">
<mx:columns>
    <mx:AdvancedDataGridColumn 
            dataField="Full_Name">
    </mx:AdvancedDataGridColumn>
</mx:columns>
<mx:rendererProviders>
    <mx:AdvancedDataGridRendererProvider 
            renderer="{rendererFactory}"
            columnSpan="0"
            columnIndex="0"
            depth="2"/>
    <mx:AdvancedDataGridRendererProvider
            renderer="{anotherFactory}"
            columnIndex="0"
            columnSpan="0"
            depth="1"/>
</mx:rendererProviders>

If you change {rendererFactory} (updating existing or creating new), it will not trigger refresh. After making changes to the factory, i did myDatagrid.rendererProviders=myDatagrid.rendererProviders and that triggered the update and recycled the renderers.

Upvotes: 2

Related Questions