How to use 2 different renderings of an element in mx: Tree

Question for guys Flex. How can I use multiple renderings of elements in mx: Tree depending on the depth / level of the element in the tree? For instance. For elements of the first level I want to use a label with a button and for the drop-down lists of elements of the second level.

How is this possible?

+3
source share
2 answers

Here is the solution: In the extended Tree, simply override the getItemRendererFactory (data: Object): IFactory function and create the necessary logic to select the correct itemRenderer.

Hope this helps someone else as well.

+2
source

. .

, : http://cookbooks.adobe.com/post_How_do_I_create_a_Tree_itemRenderer_-62.html

override public function set data(value:Object):void
        {
            if(value != null)
            { 
                super.data = value;
                if(TreeListData(super.listData).hasChildren)
                {
                    setStyle("color", 0x660099);
                    setStyle("fontWeight", 'bold');
        }
        else
        {
            setStyle("color", 0x000000);
            setStyle("fontWeight", 'normal');
        }
            }
         }  

"" , . .

+1

Source: https://habr.com/ru/post/1737851/


All Articles