Can someone point me in the right direction for a workaround for the problem described as Flex bug 28191:
Steps to reproduce:
1. Populate a Tree/List with data and provide a custom itemRenderer class factory.
2. Change the class factory and dataProvider at the same time.
3. List.createItemRenderer() will crash during since Factory is the key and it has been changed.
Crash because the renderer can not be found since it does not exist on that factory dictionary since the class factory was changed and the lookup is using the new factory.
Seems like a race condition, as sometimes during this process it skips that block of code but in other cases it falls into this block and fails.
I need to change the data provider and item renderer of a tree control at runtime. Is there one or more methods I should run to prevent this? As the bug notes state, this is an intermittent problem. The error occurs here:
if (factory == itemRenderer)
if (freeItemRenderers && freeItemRenderers.length)
renderer = freeItemRenderers.pop();
Thanks. Actually, I have been updating (not setting or changing) the tree's dataprovider, and then changing the classFactory like this:
processesXML = event.result as XML;
nodeTreeData.source = processesXML.children();
nodeTree.allowMultipleSelection = true;
nodeTree.allowMultipleSelection = false;
I had tried using validateNow after changing the ClassFactory before but did get the error again. I will try it again but update the data provider after. Since it's an intermittent error I'm finding it hard to know if a fix is really working.
Changing just the renderer, then calling validateNow() should set a flag that flushes the freeItemRenderers. It is possible that if something else is dirty (new data for example) then other code might run before the renderers get flushed.
There is a protected method called purgeItemRenderers() that actually does the flushing. I supposed you could try subclassing and calling it directly.
Thank you. Can you point me in the right direction on how and where to call that method directly? I haven't gotten into subclassing. Can you recommend a tutorial that would be helpful? Am I subclassing the tree component or something else? Thanks again.
That is also my problem....
When I try to delete a row with itemrenderer from the datagrid, the row will be deleted. But when I try to add again a row, the property of last item renderer will not be flushed or deleted.
How to remove item renderers?