Question for Flex guys. How can I use multiple item renderers in mx:Tree depending on item's depth/level in tree? For example. For the first level items I want to use label with button and for second level items combobox.
Is this somehow possible?
Question for Flex guys. How can I use multiple item renderers in mx:Tree depending on item's depth/level in tree? For example. For the first level items I want to use label with button and for second level items combobox.
Is this somehow possible?
That conditional logic should be implemented in a single itemrenderer. You can't set multiple renderers.
Here is a receipe how this can be implemented: 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');
}
}
}
That 'if' statement shows you if you have inner nodes or not. You also can specify additional property when generating the data provider.
Here is solution: In extended Tree just override function getItemRendererFactory(data:Object):IFactory and do neccessary logic to select proper itemRenderer.
Hope this will help also someone else