开发者

How do I force all Tree itemrenderers to refresh?

I have item renderers in an mx.controls.Tree that I need to refresh on demand.

I have code in the updateDisplayList that fires for only some of the visible nodes no matter what I do. I've tried triggering a change that th开发者_开发知识库ey should all be listening for; I have tried clearing and resetting the dataProvider and the itemRenderer properties.

        private function forceCategoryTreeRefresh(event : Event = null) : void
        {
            trace("forceCategoryTreeRefresh");

            var prevDataProvider : Object = CategoryTree.dataProvider;
            CategoryTree.dataProvider = null;
            CategoryTree.validateNow();
            CategoryTree.dataProvider = prevDataProvider;

            var prevItemRenderer : IFactory = CategoryTree.itemRenderer;
            CategoryTree.itemRenderer = null;

            CategoryTree.itemRenderer = prevItemRenderer as IFactory;

            _categoriesChangeDispatcher.dispatchEvent(new Event(Event.CHANGE));
        }

The nodes refresh properly when I scroll them into view (e.g. the .data gets set), but I cannot force the ones that already exist to refresh or reset themselves.

Any ideas?


Try calling this function on change event:

private function refreshList(e:Event):void{
          listName.invalidateSize();
          listName.invalidateList();
          listName.invalidateDisplayList();
          listName.validateSize(true);
          listName.validateNow();
        }

for me work quite well


Try treeView.dataProvider = treeView.dataProvider;

That should update Tree view.


ItemRenderers in Flex are virtualized so there will not always be one ItemRenderer for each Tree node.

However, you can invalidate the nodes to force a refresh. The answer to this question gives an example of how to do that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜