如何在 mx:Tree 中使用 2 个不同的项目渲染器

发布于 2024-08-26 03:33:06 字数 105 浏览 2 评论 0原文

问 Flex 人员的问题。 如何根据树中项目的深度/级别在 mx:Tree 中使用多个项目渲染器? 例如。对于第一级项目,我想使用带按钮的标签,对于第二级项目组合框。

这有可能吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独夜无伴 2024-09-02 03:33:06

这是解决方案:
在扩展树中,只需重写函数 getItemRendererFactory(data:Object):IFactory 并执行必要的逻辑来选择正确的 itemRenderer。

希望这对其他人也有帮助

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

得不到的就毁灭 2024-09-02 03:33:06

该条件逻辑应该在单个项目渲染器中实现。您无法设置多个渲染器。

以下是如何实施的收据: 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');
        }
            }
         }  

该“if”语句显示您是否有内部节点。您还可以在生成数据提供程序时指定其他属性。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文