1
votes

The question sounds trivial, just set virtualLayout to false, but that's not what I'm after.

I've got the following situation. My Flex mobile app has predefined containers, usually half the width of the total application width. The user can maximize these components, so that they take up all the available width.

Naturally, for components that show data in a List or DataGroup, the renderers have to resize. That works out of the box, but I need them to show additional information when the components are maximized. For that to work I created a very simple method to update the renderers;

private function updateRenderer():void {
            _itemRenderer.properties = {isFullScreen: _isFullScreen, headerProperties:_headerProperties, visibleColumns:_visibleColumns, optimalColWidth:_optimalColWidth, grid:this.name, fids:_fids};
            _list.itemRenderer = _itemRenderer;
}

The renderer properties, such as visibleColumns change accordingly and since the renderers will be invalidated automatically during a resize, they can redraw with the new properties.

That is all fine, but unfortunately, new renderers are created with this kind of procedure, instead of simply reusing the existing ones and let them redraw themselves.

Is there any way to alter this behavior, or does someone know a better way to accomplish a task like this?

1
This may lead into peformance issues and memory leaks. Why not use states ?Adrian Pirvulescu
No memory leaks and performance wise I don't see the issue. Where do you see potential flaws with this method of updating the renderer? But you're right, states are probably the more efficient solution, the only issue I'm having with states is the way to change them. I need the renderer to be updated based on a resize of the host component, the data object remains exactly the same though, so it doesn't carry any information about which state the renderer should be in.AlBirdie
@AdrianPirvulescu, on second thought, can't use states as the renderer properties are dynamically set by an external component. Renderer properties are for example labels and their sizes, the renderer than has to create labels according to the set properties, much like a table row with dynamic columns.AlBirdie

1 Answers

0
votes

If I understand the code you show, it replaces the itemRenderer property; so "expected" that when this occurs, that all the existing renderers will be destroyed--as they were created with the 'old' renderer--and then replaced with an instance of "new" renderer.

You may consider changing the properties directly on the renderer:

   (_list.itemRenderer as ClassFactory).properties = {isFullScreen: _isFullScreen, headerProperties:_headerProperties, visibleColumns:_visibleColumns, optimalColWidth:_optimalColWidth, grid:this.name, fids:_fids};

And then forcing your dataProvider to refresh so that all the itemRenderers are redrawn, if needed:

(_list.dataProvider as ArrayCollection).refresh()