2
votes

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?

1
do you create new classfactory?user1875642
I tried setting properties on existing factory as well as creating a new one. Neither worked.jhinkley
that is surprising. when you set grid.itemRenderer to new ClassFactory , it removes all old itemrenderers and creates new ones. Try to debug and see if purgeItemRenderers function in AdvancedDataGridBase is executed.user1875642
@user1875642 That is what I would expect! If you replace the itemRenderer factory that means all the old itemRenderers are invalid because they were created on an old itemRenderer and the component must update itself; thereby destorying the old itemRenderers and re-creating new ones.JeffryHouser
Figured it out...I'm using rendererProviders which is an array. Updating the factory inside the array doesn't seem to trigger any updates. Just need to refresh the datagrid.rendererProviders after setting the new factory.jhinkley

1 Answers

2
votes

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.